Exporting the Slow SQL Template List
Function
- This API is used to export the slow SQL template list after Collect Slow Query Logs is enabled.
- For free instances, you can only view data generated in the last hour.
- The maximum query interval is one day.
URI
GET /v3/{project_id}/instances/{instance_id}/slow-sql-templates
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Explanation: Project ID of a tenant in a region To obtain this value, see Obtaining a Project ID. Constraints: N/A Values: The value can contain 32 characters. Only letters and digits are allowed. Default value: N/A |
instance_id |
Yes |
String |
Explanation: Unique ID of an instance Constraints: N/A Values: The value can contain 32 characters. Only letters and digits are allowed. Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
start_at |
Yes |
Long |
Explanation: Start time in the Unix timestamp format, in milliseconds Constraints: N/A Values: [0, 2^31-1]. The actual value depends on the query result. Default value: N/A |
end_at |
Yes |
Long |
Explanation: End time in the Unix timestamp format, in milliseconds Constraints: N/A Values: [0, 2^31-1]. The actual value depends on the query result. Default value: N/A |
datastore_type |
Yes |
String |
Explanation: Database type Constraints: N/A Values:
Default value: N/A |
db_name |
No |
String |
Explanation: Database name Constraints: N/A Values: N/A Default value: N/A |
offset |
No |
Integer |
Explanation: Index offset. The query starts from the next piece of data indexed by this parameter. If this parameter is set to 1 and limit is set to 10, only the second to eleventh records are displayed. Constraints: N/A Values: [0, 2^31-1] Default value: 0: The query starts from the first data record. |
limit |
No |
Integer |
Explanation: Number of records to be queried. If this parameter is set to 10, a maximum of 10 records can be displayed. Constraints: N/A Values: [1, 100] Default value: 20 |
Request Parameters
None
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
slow_sql_templates |
Array of SlowSqlTemplate objects |
Explanation: Slow query log templates Values: N/A |
total_count |
Integer |
Explanation: Total number of slow query log templates Values: N/A |
Parameter |
Type |
Description |
---|---|---|
sql_template |
String |
Explanation: SQL template Values: N/A |
sql_template_id |
String |
Explanation: SQL template ID Values: N/A |
sql_sample |
String |
Explanation: SQL sample Values: N/A |
sql_sample_user |
String |
Explanation: User who executes a sample SQL statement Values: N/A |
db_names |
Array of strings |
Explanation: Database name Values: N/A |
execute_count |
Long |
Explanation: Execution times Values: N/A |
avg_execute_time |
Double |
Explanation: Average execution duration (ms) Values: N/A |
max_execute_time |
Double |
Explanation: Maximum execution duration (ms) Values: N/A |
avg_lock_wait_time |
Double |
Explanation: Average lock wait time (ms) Values: N/A |
max_lock_wait_time |
Double |
Explanation: Maximum lock wait time (ms) Values: N/A |
avg_rows_examined |
Double |
Explanation: Average rows scanned Values: N/A |
max_rows_examined |
Double |
Explanation: Maximum rows scanned Values: N/A |
avg_rows_sent |
Double |
Explanation: Average rows returned Values: N/A |
max_rows_sent |
Double |
Explanation: Maximum rows returned Values: N/A |
Example Request
Exporting the slow SQL template list
GET https://das.cn-north-1.myhuaweicloud.com/v3/054c630ff780d4cc2f40c00d7f6fb21d/instances/6243b3fcf2f948578d46ed4c52fb54eein01/slow-sql-templates?startAt=1611975464337&endAt=1611979064337&datastore_type=MySQL&db_name=db&offset=0&limit=10
Example Response
Status code: 200
Successful request
{ "slow_sql_templates" : [ { "max_rows_examined" : 0, "max_lock_wait_time" : 0, "avg_rows_examined" : 0, "execute_count" : 27, "avg_execute_time" : 5.000509315066868, "max_execute_time" : 5.008123874664307, "avg_lock_wait_time" : 0, "sql_template" : "SELECT sleep(?);", "sql_template_id": "1D7880577913B207", "sql_sample" : "select sleep(5)", "avg_rows_sent" : 1, "db_names" : [ "db_01" ], "max_rows_sent" : 1 } ], "total_count" : 1 }
Status Codes
Status Code |
Description |
---|---|
200 |
Successful request |
400 |
Client error |
500 |
Server error |
Error Codes
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