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

Exporting SQL Execution Time Distribution

Function

  • This API is used to export the SQL execution duration after Top SQL is enabled.
  • This function is only available for paid instances.
  • The maximum query interval is six hours.

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:listTopSql

    List

    Instance

    -

    das:clouddba:topSqlList

    -

URI

GET /v3/{project_id}/instances/{instance_id}/top-sql-trend

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, including only letters and digits.

Default Value

N/A

instance_id

Yes

String

Definition

Unique ID of an instance

Constraints

N/A

Range

The value can contain 32 characters, including only letters and digits.

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

node_id

No

String

Definition

Node ID

Constraints

N/A

Range

The value can contain 32 characters, including only letters and digits.

Default Value

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

interval_millis

Long

Definition

Query interval

Range

The interval is 10s if the query duration is within one hour, 60s if the query duration is within six hours, and 300s if the query duration is longer than six hours. The unit is millisecond.

top_sql_trend_items

Array of TopSqlTrendItem objects

Definition

SQL execution time distribution

Range

N/A

total_count

Integer

Definition

Total execution time ranges

Range

N/A

Table 4 TopSqlTrendItem

Parameter

Type

Description

execute_at

Long

Definition

Execution time, in milliseconds

Range

The value ranges from execute_atinterval_millis to execute_at.

query_time_in_100ms

Long

Definition

SQL statements executed within 100 ms

Range

N/A

query_time_in_500ms

Long

Definition

SQL statements that take 100 ms to 500 ms to execute

Range

N/A

query_time_in_1s

Long

Definition

SQL statements that take 500 ms to 1000 ms to execute

Range

N/A

query_time_over_1s

Long

Execution duration more than 1000 ms.

Definition

SQL statements that take more than 1000 ms to execute

Range

N/A

Example Requests

Exporting SQL execution time distribution

GET https://das.cn-north-1.myhuaweicloud.com/v3/054c630ff780d4cc2f40c00d7f6fb21d/instances/6243b3fcf2f948578d46ed4c52fb54eein01/top-sql-trend?start_at=1611975464337&end_at=1611979064337&datastore_type=MySQL&node_id=fec05693c76c4f389561051db430324cno01

Example Responses

Status code: 200

Successful response

{
  "top_sql_trend_items" : [ {
    "execute_at" : 1666702330000,
    "query_time_over_1s" : 1,
    "query_time_in_100ms" : 3,
    "query_time_in_1s" : 0,
    "query_time_in_500ms" : 0
  }, {
    "execute_at" : 1666702340000,
    "query_time_over_1s" : 2,
    "query_time_in_100ms" : 2,
    "query_time_in_1s" : 0,
    "query_time_in_500ms" : 0
  } ],
  "interval_millis" : 10000,
  "total_count" : 2
}

Status Codes

Status Code

Description

200

Successful response

400

Client error

500

Server error

Error Codes

See Error Codes.