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

Exporting SQL Execution Time Distribution

Function

This API is used to export the SQL execution duration after the TopSQL switch is turned on. This function is available only for paid instances. The maximum query interval is six hours.

URI

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

Table 1 URI parameters

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

Table 2 Query parameters

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:

  • MySQL
  • TaurusDB

Default value:

N/A

node_id

No

String

Explanation:

Node ID

Constraints:

N/A

Values:

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

Default value:

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

interval_millis

Long

Explanation:

Query interval

Values:

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

Explanation:

SQL execution time distribution

Values:

N/A

total_count

Integer

Explanation:

Total execution time ranges

Values:

N/A

Table 4 TopSqlTrendItem

Parameter

Type

Description

execute_at

Long

Explanation:

Execution time, in milliseconds

Values:

The value ranges from execute_atinterval_millis to execute_at.

query_time_in_100ms

Long

Explanation:

SQL statements executed within 100 ms

Values:

N/A

query_time_in_500ms

Long

Explanation:

SQL statements that take 100 ms to 500 ms to execute

Values:

N/A

query_time_in_1s

Long

Explanation:

SQL statements that take 500 ms to 1000 ms to execute

Values:

N/A

query_time_over_1s

Long

Execution duration more than 1000 ms.

Explanation:

SQL statements that take more than 1000 ms to execute

Values:

N/A

Example Request

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 Response

Status code: 200

Successful request

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

400

Client error

500

Server error

Error Codes

See Error Codes.