Exporting the Slow SQL Template List
Function
This API is used to export slow SQL template list after Slow Query Log is enabled. This function is available only for paid instances. 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 |
Project ID. To obtain this value, see Obtaining a Project ID. |
instance_id |
Yes |
String |
Instance ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
start_at |
Yes |
Long |
Start time in Unix timestamp format, in milliseconds. |
end_at |
Yes |
Long |
End time in Unix timestamp format, in milliseconds. |
datastore_type |
Yes |
String |
Database type, which can be MySQL and TaurusDB |
db_name |
No |
String |
Database name. |
offset |
No |
Integer |
Offset. If offset is set to N, the resource query starts from the N+1 piece of data. The value is 0 by default, indicating that the query starts from the first piece of data. The value must be a number but cannot be a negative number. |
limit |
No |
Integer |
Number of records displayed on each page. The default value is 20 and the maximum value is 100. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. |
X-Language |
No |
String |
Request language type. Enumerated values:
|
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
slow_sql_templates |
Array of SlowSqlTemplate objects |
Slow query log templates. |
total_count |
Integer |
Total number of slow query log templates. |
Parameter |
Type |
Description |
---|---|---|
sql_template |
String |
SQL template |
sql_sample |
String |
Sample SQL statement |
sql_sample_user |
String |
User who executes a sample SQL statement |
db_names |
Array of strings |
Database name. |
execute_count |
Long |
Execution times |
avg_execute_time |
Double |
Avg. execution duration (ms). |
max_execute_time |
Double |
Maximum execution duration (ms). |
avg_lock_wait_time |
Double |
Avg. lock wait time (ms). |
max_lock_wait_time |
Double |
Max. lock wait time (ms). |
avg_rows_examined |
Double |
Avg. rows scanned. |
max_rows_examined |
Double |
Max. rows scanned. |
avg_rows_sent |
Double |
Avg. rows returned. |
max_rows_sent |
Double |
Max. rows returned. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Minimum length: 8 characters Maximum length: 36 characters |
error_msg |
String |
Error message. Minimum length: 2 characters Maximum length: 512 characters |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Minimum length: 8 characters Maximum length: 36 characters |
error_msg |
String |
Error message. Minimum length: 2 characters Maximum length: 512 characters |
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
Success
{ "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_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 |
Success |
400 |
Client error |
500 |
Server error |
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