Help Center/ Data Admin Service/ API Reference/ APIs (in OBT)/ Cloud DBA/ Exporting Slow SQL Template List
Updated on 2024-08-05 GMT+08:00

Exporting Slow SQL Template List

Function

This API is used to export slow SQL template list after the exporting slow SQL template list switch is turned on. 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

Table 1 Path parameters

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.

Table 2 Query parameters

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. The options can be: RDS for MySQL and GaussDB(for MySQL) databases.

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

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

X-Language

No

String

Request language type.

The value can be:

  • en-us
  • zh-cn

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

slow_sql_templates

Array of SlowSqlTemplate objects

Slow query log templates.

total_count

Integer

Total number of slow query log templates.

Table 5 SlowSqlTemplate

Parameter

Type

Description

sql_template

String

SQL templates.

sql_sample

String

Example SQL.

db_names

Array of strings

Database name.

execute_count

Long

Number of executions.

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

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 8

Maximum length: 36

error_msg

String

Error message.

Minimum length: 2

Maximum length: 512

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 8

Maximum length: 36

error_msg

String

Error message.

Minimum length: 2

Maximum length: 512

Example Requests

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 Responses

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 Code

Status Code

Description

200

Success.

400

Client error.

500

Server error.

Error Code

For details, see Error Codes.