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

Exporting Slow Query Log Statistics

Function

This API is used to export slow query log statistics after Collect Slow Query Logs is enabled.

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

    read

    -

    -

    -

    -

URI

POST /v3/{project_id}/instances/{instance_id}/slow-sql-statistics

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

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

datastore_type

Yes

String

Definition

Database type

Constraints

N/A

Range

  • DDS-Community

Default Value

N/A

start_at

Yes

Long

Definition

Start time

Constraints

Unix timestamp, in milliseconds

Range

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

Default Value

N/A

end_at

Yes

Long

Definition

End time

Constraints

Unix timestamp, in milliseconds

Range

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

Default Value

N/A

node_ids

No

Array of strings

Definition

Node ID list

Constraints

Multiple values need to be separated by commas (,).

Range

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

Default Value

N/A

statistics_field

No

String

Definition

Statistics field

Constraints

N/A

Range

  • node_id
  • sql_type
  • db_name
  • collection
  • user
  • client

Default Value

node_id

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

Records on each page

Constraints

N/A

Range

[1, 100]

Default Value

20

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

statistics_list

Array of Table 4 objects

Definition

Slow SQL statement statistics

Range

N/A

total_count

Integer

Definition

Total number

Range

[0, 2^31-1]

Table 4 SlowSqlStatistics

Parameter

Type

Description

execute_count

Long

Definition

Execution times

Range

N/A

avg_execute_time

Double

Definition

Average execution duration (s)

Range

N/A

max_execute_time

Double

Definition

Maximum execution duration (s)

Range

N/A

avg_lock_wait_time

Double

Definition

Average lock wait time (s)

Range

N/A

max_lock_wait_time

Double

Definition

Maximum lock wait time (s)

Range

N/A

avg_rows_sent

Double

Definition

Average number of returned documents

Range

N/A

max_rows_sent

Double

Definition

Maximum number of returned documents

Range

N/A

avg_rows_examined

Double

Definition

Average number of scanned documents

Range

N/A

max_rows_examined

Double

Definition

Maximum number of scanned documents

Range

N/A

avg_key_examined

Double

Definition

Average number of scanned indexes

Range

N/A

max_key_examined

Double

Definition

Maximum number of scanned indexes

Range

N/A

node_id

String

Definition

Node ID, which is assigned when statistics_field is set to node_id

Range

N/A

node_name

String

Definition

Node name, which is assigned when statistics_field is set to node_id

Range

N/A

sql_type

String

Definition

Statement type, which is assigned when statistics_field is set to sql_type

Range

N/A

db_name

String

Definition

Database name, which is assigned when statistics_field is set to db_name or collection

Range

N/A

collection

String

Definition

Database table, which is assigned when statistics_field is set to collection

Range

N/A

user

String

Definition

Username, which is assigned when statistics_field is set to user

Range

N/A

client

String

Definition

Client, which is assigned when statistics_field is set to client

Range

N/A

Example Requests

Exporting slow query logs

POST  https://das.cn-north-1.myhuaweicloud.com/v3/054c630ff780d4cc2f40c00d7f6fb21d/instances/6243b3fcf2f948578d46ed4c52fb54eein02/slow-sql-statistics

Example Responses

Status code: 200

Successful response

{  "statistics_list": [
{
"execute_count": 6,
"avg_execute_time": 5.000509315066868,
"max_execute_time": 5.008123874664307,
"avg_lock_wait_time": 1,
"max_lock_wait_time": 1,
"avg_rows_sent": 1,
"max_rows_sent": 1,
"avg_rows_examined": 0,
"max_rows_examined": 0,
"avg_key_examined": 0,
"max_key_examined": 0,
"node_id": "fec05693c76c4f389561051db430324cno02",
"node_name": "dds-1234_node_1"
}
],
"total_count": 1
}

Status Codes

Status Code

Description

200

Successful response

400

Client error

500

Server error

Error Codes

See Error Codes.