Querying Details of Slow SQL Statements in the Global Table
Function
This API is used to query details about slow SQL statements of a specified component based on a unique SQL ID.
- Learn how to authenticate this API.
- Obtain the required region and endpoint.
Debugging
You can debug this API in API Explorer.
Constraints
This API is suitable only for nodes with CNs or DNs (primary or standby DNs).
URI
POST /v3/{project_id}/instances/{instance_id}/global-slow-sql-detail
Parameter |
Mandatory |
Description |
---|---|---|
project_id |
Yes |
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 |
Definition Instance ID, which uniquely identifies an instance. Constraints N/A Range The value can contain 36 characters. Only letters and digits are allowed. 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. The value of X-Subject-Token in the response 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 |
---|---|---|---|
start_time |
Yes |
Long |
Definition Start date. Constraints The value is a 13-digit UNIX timestamp, in milliseconds. The time zone is UTC. Range N/A Default Value N/A |
end_time |
Yes |
Long |
Definition End date. Constraints The value is a 13-digit UNIX timestamp, in milliseconds. The time zone is UTC. Range N/A Default Value N/A |
instance_id |
Yes |
String |
Definition Instance ID. Constraints N/A Range N/A Default Value N/A |
sql_id |
Yes |
String |
Definition ID of a slow SQL statement. Constraints N/A Range N/A Default Value N/A |
node_ids |
Yes |
Array of strings |
Definition Node IDs. Constraints The node ID array cannot be empty. |
component_type |
Yes |
String |
Definition Component type. Constraints N/A Range
Default Value N/A |
Response Parameters
Parameter |
Type |
Description |
---|---|---|
total |
Integer |
Definition Total number of slow SQL statements. Range N/A |
slow_sql_details |
Array of objects |
Definition Details of slow SQL statements. For details, see Table 5. |
Parameter |
Type |
Description |
---|---|---|
db_name |
String |
Definition Database name. Range N/A |
schema_name |
String |
Definition Schema name. Range N/A |
sql_id |
String |
Definition SQL ID. Range N/A |
user_name |
String |
Definition Username. Range N/A |
client_ip |
String |
Definition Client IP address. Range N/A |
client_port |
String |
Definition Client port. Range N/A |
node_id |
String |
Definition Node ID. Range N/A |
node_name |
String |
Definition Node name. Range N/A |
sql_text |
String |
Definition SQL template. Range N/A |
sql |
String |
Definition Complete SQL statement after variable replacement. If sql_text does not contain variable values, sql returns an empty string. Range N/A |
query_plan |
String |
Definition Execution plan. Range N/A |
start_time |
Integer |
Definition Start time in the format of yyyy-mm-ddThh:mm:ss+0000 (UTC time). Range N/A |
finish_time |
Integer |
Definition End time in the format of yyyy-mm-ddThh:mm:ss+0000 (UTC time). Range N/A |
returned_rows |
Integer |
Definition Returned rows. Range N/A |
fetched_rows |
Integer |
Definition Fetched rows. Range N/A |
fetched_pages |
Integer |
Definition Fetched pages. Range N/A |
hit_pages |
Integer |
Definition Hit pages. Range N/A |
total_time |
Integer |
Definition Total time, in microseconds. Range N/A |
cpu_time |
Integer |
Definition CPU time, in microseconds. Range N/A |
plan_time |
Integer |
Definition Plan time, in microseconds. Range N/A |
io_time |
Integer |
Definition I/O time, in microseconds. Range N/A |
lock_count |
Integer |
Definition Number of locks. Range N/A |
lock_time |
Integer |
Definition Lock time, in microseconds. Range N/A |
Example Request
Querying details of slow SQL statements in the global table
POST https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/d04686c6baae4f65a742771186f47b7ain14/global-slow-sql-detail { "instance_id" : "d04686c6baae4f65a742771186f47b7ain14", "node_ids" : [ "88391813e1cb4e93899b210e880fdb1bno20" ], "start_time" : 1686903754933, "end_time" : 1686990154933, "sql_id" : 123, "component_type" : "dn" }
Example Response
Details of slow SQL statements queried.
{ "slow_sql_details" : [ { "db_name": "db_tpcc", "schema_name": "db_tpcc", "sql_id" : "12345", "user_name" : "john_doe", "client_ip" : "192.168.0.1", "client_port" : "5432", "sql_text" : "SELECT * FROM large_table WHERE column1 = 'value';", "sql" : "", "query_plan" : "Seq Scan on large_table ...", "start_time" : "2024-03-26 11:23:47 +0000", "finish_time" : "2024-03-26 11:23:51 +0000", "returned_rows" : 1000, "fetched_rows" : 5000, "fetched_pages" : 50, "hit_pages" : 25, "total_time" : "79.2812", "cpu_time" : "0.0170", "plan_time" : "0.0001", "io_time" : "0.0045", "lock_count" : 1, "lock_time" : "0.0000", "node_id" : "88391813e1cb4e93899b210e880fdb1bno20", "node_name" : "Node1" } ], "total" : 1 }
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