Querying Details of a Slow SQL Statement
Function
This API is used to query details of a SQL statement based on the normalized SQL ID. 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.
Constraints
This API is suitable only for nodes with CNs or DNs (primary or standby DNs).
URI
POST /v3/{project_id}/instances/{instance_id}/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. 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 |
---|---|---|---|
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 the slow SQL statement. Constraints N/A Range N/A Default Value N/A |
node_ids |
Yes |
Array of strings |
Definition Node ID. Constraints The value cannot be left blank. |
multi_queries |
No |
Array of MultiMergeCondition |
Definition Query conditions for field aggregation. For details, see Table 4. Constraints Only full AND or full OR queries can be performed on the query field. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Definition Name of the field to be queried. Constraints Only the character string query is supported. Range 1 to 128 characters, including letters (case-sensitive), digits, and underscores (_) Default Value N/A |
condition |
String |
Definition Combined condition. Constraints N/A Range The value can only be and, or, AND or OR. Default Value N/A |
values |
Array of strings |
Definition Set of multiple search criteria. The value is a list of 1 to 5 characters. Constraints N/A |
is_fuzzy |
Boolean |
Definition Set of multiple search criteria. Constraints The value can only be true for fuzzy query. Range
Default Value true |
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 6. |
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 IP address of the client. Range N/A |
client_port |
String |
Definition Port of the client. 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 a slow SQL statement
POST https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/d04686c6baae4f65a742771186f47b7ain14/slow-sql-detail
{
"instance_id" : "d04686c6baae4f65a742771186f47b7ain14",
"node_ids" : [ "88391813e1cb4e93899b210e880fdb1bno20" ],
"start_time" : 1686903754933,
"end_time" : 1686990154933,
"sql_id" : 123,
"multi_queries": [ { "name": "query", "condition": "AND", "is_fuzzy": true, "values": [ "slelect", "from table" ] } ]
}
Example Response
Details of the slow SQL statement 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