Help Center/ Data Admin Service/ API Reference/ APIs (in OBT)/ Intelligent O&M/ Exporting the Slow SQL Template List
Updated on 2026-01-20 GMT+08:00

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.

Authorization Information

Each account has permissions to call all APIs, but IAM users must have the required permissions specifically assigned.

  • If you are using role/policy-based authorization, see the required permissions in Permissions Policies and Supported Actions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    das:clouddba:slowSqlExport

    list

    Instance

    -

    -

    -

URI

GET /v3/{project_id}/instances/{instance_id}/slow-sql-templates

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region

To obtain this 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

String

Definition

Unique ID of an instance

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are allowed.

Default Value

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

start_at

Yes

Long

Definition

Start time in the Unix timestamp format, in milliseconds

Constraints

N/A

Range

[0, 2^31-1]. The actual value depends on the query result.

Default Value

N/A

end_at

Yes

Long

Definition

End time in the Unix timestamp format, in milliseconds

Constraints

N/A

Range

[0, 2^31-1]. The actual value depends on the query result.

Default Value

N/A

datastore_type

Yes

String

Definition

Database type

Constraints

N/A

Range

  • MySQL
  • TaurusDB

Default Value

N/A

db_name

No

String

Definition

Database name

Constraints

N/A

Range

N/A

Default Value

N/A

offset

No

Integer

Definition

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

Range

[0, 2^31-1]

Default Value

0: The query starts from the first data record.

limit

No

Integer

Definition

Number of records to be queried. If this parameter is set to 10, a maximum of 10 records can be displayed.

Constraints

N/A

Range

[1, 100]

Default Value

20

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

slow_sql_templates

Array of SlowSqlTemplate objects

Definition

Slow query log templates

Range

N/A

total_count

Integer

Definition

Total number of slow query log templates

Range

N/A

Table 4 SlowSqlTemplate

Parameter

Type

Description

sql_template

String

Definition

SQL template

Range

N/A

sql_template_id

String

Definition

SQL template ID

Range

N/A

sql_sample

String

Definition

SQL sample

Range

N/A

sql_sample_user

String

Definition

User who executes a sample SQL statement

Range

N/A

db_names

Array of strings

Definition

Database name

Range

N/A

execute_count

Long

Definition

Execution times

Range

N/A

avg_execute_time

Double

Definition

Average execution duration (ms)

Range

N/A

max_execute_time

Double

Definition

Maximum execution duration (ms)

Range

N/A

avg_lock_wait_time

Double

Definition

Average lock wait time (ms)

Range

N/A

max_lock_wait_time

Double

Definition

Maximum lock wait time (ms)

Range

N/A

avg_rows_examined

Double

Definition

Average rows scanned

Range

N/A

max_rows_examined

Double

Definition

Maximum rows scanned

Range

N/A

avg_rows_sent

Double

Definition

Average rows returned

Range

N/A

max_rows_sent

Double

Definition

Maximum rows returned

Range

N/A

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

Successful response

{ 
  "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 response

400

Client error

500

Server error

Error Codes

See Error Codes.