Help Center/ Data Admin Service/ API Reference/ APIs (in OBT)/ Cloud DBA/ Exporting SQL Execution Time Distribution
Updated on 2024-08-05 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 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.

node_id

No

String

Node ID.

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

interval_millis

Long

Interval between two time points in the list. The query interval is 10s within one hour, 60s from one hour to six hours, and 300s within more than six hours. The unit is millisecond.

top_sql_trend_items

Array of TopSqlTrendItem objects

SQL execution time distribution.

total_count

Integer

Total execution time ranges.

Table 5 TopSqlTrendItem

Parameter

Type

Description

execute_at

Long

Execution time point in milliseconds. The time range for statistics is collected from execute_at - interval_millis to execute_at.

query_time_in_100ms

Long

Execution duration less than 100 ms.

query_time_in_500ms

Long

Execution duration from 100 ms to 500 ms.

query_time_in_1s

Long

Execution duration from 500 ms to 1000 ms.

query_time_over_1s

Long

Execution duration more than 1000 ms.

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

Success

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

Status Code

Description

200

Success.

400

Client error.

500

Server error.

Error Code

For details, see Error Codes.