Querying Details of a Single SQL Statement
Function
This API is used to query details of a single SQL statement. For a distributed instance, you can query the complete execution records of a SQL statement, including the SQL statement execution history on both CNs and DNs. Before calling this API:
- Learn how to authenticate this API.
- Obtain the required region and endpoint.
Debugging
You can debug this API in API Explorer.
URI
GET /v3/{project_id}/instances/{instance_id}/full-sqls/{sql_exec_id}
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition Project ID of a tenant in a region. To obtain the value, see Obtaining a Project ID. Constraints N/A Range The value can contain 32 characters. Only letters and digits are allowed. Default Value N/A |
|
instance_id |
Yes |
String |
Definition Instance ID. Constraints N/A Range N/A Default Value N/A |
|
sql_exec_id |
Yes |
String |
Definition Unique SQL ID, which corresponds to the kernel parameter debug_query_id. Constraints N/A Range N/A Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition User token. You can obtain the token by calling the IAM API used to obtain a user token. After the request is processed, the value of X-Subject-Token in the message header is the token value. Constraints N/A Range N/A Default Value N/A |
|
X-Language |
No |
String |
Definition Language. Constraints N/A Range
Default Value en-us |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
Integer |
Definition Unique key ID of the collected full SQL statement records. Constraints N/A Range N/A Default Value N/A |
|
sql_id |
No |
String |
Definition Normalized SQL ID, which corresponds to the kernel parameter unique_sql_id. Constraints N/A Range N/A Default Value N/A |
Response Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
trace_statistics |
Object |
Definition Link details. For details, see Table 5. Constraints This parameter is valid only when sql_id is specified and id is empty in the query parameters. |
|
components |
Array |
Definition SQL statement execution records on components. For details, see Table 6. |
|
Parameter |
Type |
Description |
|---|---|---|
|
hit_rate |
Double |
Definition Hit rate. Range N/A |
|
db_time |
Long |
Definition Valid DB time. Range N/A |
|
cpu_time |
Long |
Definition CPU time (unit: μs). Range N/A |
|
io_time |
Long |
Definition I/O time (unit: μs). Range N/A |
|
execution_time |
Long |
Definition Execution time in the executor (unit: μs). Range N/A |
|
scan_rows |
Long |
Definition Scanned rows. Range N/A |
|
update_rows |
Long |
Definition Updated rows. Range N/A |
|
insert_rows |
Long |
Definition Inserted rows. Range N/A |
|
delete_rows |
Long |
Definition Deleted rows. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
component_id |
String |
Definition Component ID. Range N/A |
|
db_name |
String |
Definition Database name. Range N/A |
|
schema_name |
String |
Definition Schema name. Range N/A |
|
origin_node |
String |
Definition Original node. Range N/A |
|
username |
String |
Definition Username. Range N/A |
|
application_name |
String |
Definition Name of the application that sends a request. Range N/A |
|
client_addr |
String |
Definition IP address of the client that initiated the request. Range N/A |
|
client_port |
String |
Definition Port number of the client that initiated the request. Range N/A |
|
parent_sql_id |
String |
Definition Normalized SQL ID of the outer SQL statement. Range N/A |
|
sql_id |
String |
Definition Normalized SQL ID, which corresponds to the kernel parameter unique_sql_id. Range N/A |
|
sql_exec_id |
String |
Definition Unique SQL ID, which corresponds to the kernel parameter debug_query_id. Range N/A |
|
transaction_id |
String |
Definition Transaction ID, which corresponds to the kernel parameter debug_query_id. Range N/A |
|
trace_id |
String |
Definition Link ID. Range N/A |
|
query |
String |
Definition Normalized SQL statement. Range N/A |
|
sql |
String |
Definition Original SQL text after parsing. When track_stmt_parameter is enabled, variables in the collected SQL text are replaced with their actual values, so you can see the original SQL statement. However, for SQL text collected when track_stmt_parameter is disabled, the original values of the variables cannot be retrieved, and no content will be displayed here. Range N/A |
|
thread_id |
String |
Definition Thread ID. Range N/A |
|
session_id |
String |
Definition Session ID. Range N/A |
|
start_time |
String |
Definition Start time in the yyyy-mm-ddThh:mm:ss.SSSSSZ format. Range N/A |
|
finish_time |
String |
Definition End time in the yyyy-mm-ddThh:mm:ss.SSSSSZ format. Range N/A |
|
slow_query_threshold |
Long |
Definition Slow SQL threshold. Range N/A |
|
n_soft_parse |
Long |
Definition Number of soft parsing times. Range N/A |
|
n_hard_parse |
Long |
Definition Number of hard parsing times. Range N/A |
|
query_plan |
String |
Definition Execution plan. Range N/A |
|
n_returned_rows |
Long |
Definition Number of rows in the result set returned by the SELECT statement. Range N/A |
|
n_tuples_fetched |
Long |
Definition Number of rows randomly scanned. Range N/A |
|
n_tuples_returned |
Long |
Definition Number of rows sequentially scanned. Range N/A |
|
n_tuples_inserted |
Long |
Definition Number of rows inserted. Range N/A |
|
n_tuples_updated |
Long |
Definition Number of rows updated. Range N/A |
|
n_tuples_deleted |
Long |
Definition Number of rows deleted. Range N/A |
|
n_blocks_fetched |
Long |
Definition Number of buffer block access times. Range N/A |
|
n_blocks_hit |
Long |
Definition Number of buffer block hits. Range N/A |
|
db_time |
Long |
Definition Valid DB time. Range N/A |
|
cpu_time |
Long |
Definition CPU time (unit: μs). Range N/A |
|
execution_time |
Long |
Definition Execution time in the executor (unit: μs). Range N/A |
|
parse_time |
Long |
Definition SQL parsing time (unit: μs). Range N/A |
|
plan_time |
Long |
Definition Execution time in the executor (unit: μs). Range N/A |
|
rewrite_time |
Long |
Definition SQL rewriting time (unit: μs). Range N/A |
|
pl_execution_time |
Long |
Definition Execution time of PL/pgSQL (unit: μs). Range N/A |
|
pl_compilation_time |
Long |
Definition Compilation time of PL/pgSQL (unit: μs). Range N/A |
|
data_io_time |
Long |
Definition I/O time (unit: μs). Range N/A |
|
lock_count |
Long |
Definition Number of locks acquired. Range N/A |
|
lock_time |
Long |
Definition Time required for acquiring locks. Range N/A |
|
lock_wait_count |
Long |
Definition Number of lock waits. Range N/A |
|
lock_wait_time |
Long |
Definition Lock wait time. Range N/A |
|
details |
String |
Definition Details. Range N/A |
|
is_slow_sql |
Boolean |
Definition Whether the SQL statement is slow. Range N/A |
|
advise |
String |
Definition Risk information that may cause the SQL statement to be slow. Range N/A |
|
finish_status |
String |
Definition Statement completion status. Range N/A |
|
net_send_info |
String |
Definition Physical connection send status. Range N/A |
|
net_recv_info |
String |
Definition Physical connection receive status. Range N/A |
|
net_stream_send_info |
String |
Definition Logical connection send status. Range N/A |
|
net_stream_recv_info |
String |
Definition Logical connection receive status. Range N/A |
Example Request
Querying details of a single SQL statement
GET https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/4a89780fa1024361bcb855fed6aab89e/instances/cf9c879513144362bce2b3760ed81d3bin14/full-sqls/72620543991485094?sql_id=67570929&f084ca811d62f93af3dff2d508a981bc
Example Response
{
"components": [
{
"component_id": "cn_5001",
"db_name": "postgres",
"schema_name": "\"$user\",public",
"origin_node": "1120683504",
"username": "rdsAdmin",
"application_name": "cm_agent",
"client_addr": "127.0.0.1",
"client_port": "57386",
"parent_sql_id": "0",
"sql_id": "2892486021",
"sql_exec_id": "72620543998347760",
"transaction_id": "0",
"query": "SET query_dop = 1;",
"sql": "",
"thread_id": "139890949678656",
"session_id": "139890949678656",
"start_time": "2025-09-10 02:01:44 +0000",
"finish_time": "2025-09-10 02:01:44 +0000",
"slow_query_threshold": "0",
"n_soft_parse": 0,
"n_hard_parse": 0,
"query_plan": "",
"n_returned_rows": 0,
"n_tuples_fetched": 0,
"n_tuples_returned": 0,
"n_tuples_inserted": 0,
"n_tuples_updated": 0,
"n_tuples_deleted": 0,
"n_blocks_fetched": 0,
"n_blocks_hit": 0,
"db_time": 462,
"cpu_time": 399,
"execution_time": 0,
"parse_time": 9,
"plan_time": 0,
"rewrite_time": 0,
"pl_execution_time": 0,
"pl_compilation_time": 0,
"data_io_time": 0,
"lock_count": 3,
"lock_time": 0,
"lock_wait_count": 0,
"lock_wait_time": 0,
"details": "{\"totalLen\":137,\"version\":2,\"events\":[{\"type\":\"IO\",\"name\":\"BufHashTableSearch\",\"duration\":5},{\"type\":\"STATE\",\"name\":\"flush data\",\"duration\":23},{\"type\":\"STATE\",\"name\":\"wait xact start command\",\"duration\":26},{\"type\":\"STATE\",\"name\":\"wait xact commit command\",\"duration\":29}]}",
"is_slow_sql": true,
"trace_id": "",
"advise": "",
"finish_status": "normal",
"net_send_info": "{\"time\":30, \"n_calls\":2, \"size\":84}",
"net_recv_info": "{\"time\":47, \"n_calls\":2, \"size\":53}",
"net_stream_send_info": "{\"time\":0, \"n_calls\":0, \"size\":0}",
"net_stream_recv_info": "{\"time\":0, \"n_calls\":0, \"size\":0}"
}
],
"trace_statistics": {
"hit_rate": 0.0,
"db_time": 462,
"cpu_time": 399,
"io_time": 0,
"execution_time": 0,
"scan_rows": 0,
"update_rows": 0,
"insert_rows": 0,
"delete_rows": 0
}
}
Status Codes
- Normal
- Abnormal
For details, see Status Codes.
Error Codes
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot