tencent cloud

TDSQL Boundless

SHOW PROFILES

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-05-29 10:14:50

Feature Description

SHOW PROFILES displays the resource usage of the most recent statements sent to the server. SHOW PROFILE is used to view the time distribution across each execution stage (Status) of a specified statement, facilitating performance analysis and bottleneck identification.
After you enable the Profiling feature, TDSQL Boundless records information about the statements executed in the current session, including the statement ID, execution duration, and statement text.

Prerequisites

Before you execute this feature, enable Profiling in the current session:
SET profiling = 1;

Syntax

SHOW PROFILES;

SHOW PROFILE [type [, type] ...] [FOR QUERY n] [LIMIT row_count [OFFSET offset]];

type: {
ALL
| BLOCK IO
| CONTEXT SWITCHES
| CPU
| IPC
| MEMORY
| PAGE FAULTS
| SOURCE
| SWAPS
}

Examples

Example 1: Viewing the List of Recently Executed Statements

tdsql > SET profiling = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

tdsql > SELECT COUNT(*) FROM test.t1;
+----------+
| COUNT(*) |
+----------+
| 1024 |
+----------+
1 row in set (0.02 sec)

tdsql > SHOW PROFILES;
+----------+------------+------------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------------+
| 1 | 0.02158725 | SELECT COUNT(*) FROM test.t1 |
+----------+------------+------------------------------+
1 row in set (0.00 sec)
The fields in the above return results are described as follows:
Query_ID: the ID of a statement in the current session.
Duration: the total execution duration of a statement, in seconds.
Query: the text of a statement.

Example 2: Viewing the Time Consumption of Each Stage for a Specified Statement

tdsql > SHOW PROFILE FOR QUERY 1;
+-----------------------+----------+
| Status | Duration |
+-----------------------+----------+
| starting | 0.000089 |
| Executing hook on txn | 0.000005 |
| starting | 0.000010 |
| checking permissions | 0.000007 |
| Opening tables | 0.000038 |
| init | 0.000034 |
| System lock | 0.000009 |
| Wait gts rsp | 0.001235 |
| Searching range cache | 0.018652 |
| optimizing | 0.000015 |
| statistics | 0.000142 |
| preparing | 0.000023 |
| executing | 0.001120 |
| end | 0.000005 |
| query end | 0.000009 |
| closing tables | 0.000012 |
| freeing items | 0.000056 |
| cleaning up | 0.000017 |
+-----------------------+----------+
18 rows in set (0.00 sec)
The fields in the above return results are described as follows:
Status: the name of the stage in which a statement is executed.
Duration: the time consumed by this stage, in seconds.
Descriptions of some key stages:
Wait gts rsp: the time spent waiting for a response from GTS (global timestamp).
Searching range cache: the time spent searching the range cache. This status is added by TDSQL Boundless to isolate the time spent searching the range cache from Wait gts rsp, facilitating precise identification of the source of time consumption.
System lock: the time spent waiting for a system lock.
Opening tables: the time spent opening tables.

Example 3: Viewing CPU and BLOCK IO Information for a Specified Statement

tdsql > SHOW PROFILE CPU, BLOCK IO FOR QUERY 1;
+-----------------------+----------+----------+------------+--------------+---------------+
| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |
+-----------------------+----------+----------+------------+--------------+---------------+
| starting | 0.000089 | 0.000076 | 0.000012 | 0 | 0 |
| Wait gts rsp | 0.001235 | 0.000080 | 0.000020 | 0 | 0 |
| Searching range cache | 0.018652 | 0.015230 | 0.003410 | 16 | 0 |
| executing | 0.001120 | 0.001100 | 0.000018 | 0 | 0 |
| cleaning up | 0.000017 | 0.000015 | 0.000002 | 0 | 0 |
+-----------------------+----------+----------+------------+--------------+---------------+
The newly added fields in the above return results are described as follows:
CPU_user: the CPU time spent in user mode, in seconds.
CPU_system: the CPU time spent in kernel mode, in seconds.
Block_ops_in: the number of block device read operations.
Block_ops_out: the number of block device write operations.

Parameter Description

SHOW PROFILE supported type options:
ALL: displays all information.
BLOCK IO: displays the number of block device input and output operations.
CONTEXT SWITCHES: displays the number of voluntary and involuntary context switches.
CPU: displays the CPU time spent in user mode and kernel mode.
IPC: displays the number of messages sent and received.
MEMORY: not yet implemented.
PAGE FAULTS: displays the number of major and minor page faults.
SOURCE: displays the source file name where the function resides, the function name, and the line number.
SWAPS: displays the number of swaps.

Limitations

SHOW PROFILES and SHOW PROFILE only display statements executed in the current session. The historical records are lost after the session is disconnected.
The number of historical statements retained is controlled by the session variable profiling_history_size, with a default of 15 and a maximum of 100.
This feature is marked as Deprecated in the official MySQL documentation. It is recommended to use it in conjunction with Performance Schema to obtain more comprehensive performance analysis capabilities.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック