All Products
Search
Document Center

Database Autonomy Service:DescribeSlowLogStatistic

Last Updated:Nov 17, 2025

Retrieves statistics for slow query logs.

Operation description

Before you call this operation, make sure that you understand the billing methods and pricing of Database Autonomy Service (DAS).

Before you call this operation, make sure that the following requirements are met:

  • Alibaba Cloud Managed Services is enabled for the instance.

  • Use the latest version of the Alibaba Cloud software development kit (SDK) or DAS SDK.

  • When you use an SDK to call the DAS API, set the region to `cn-shanghai`.

This is an asynchronous operation. After a request is sent, the system does not immediately return the complete result. If the IsFinish parameter in the response is false, wait for 1 second and send the request again. Repeat the request until the IsFinish parameter is true, at which point the complete result is returned.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

hdm:DescribeSlowLogStatistic

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the instance.

NodeId

string

No

The ID of the node.

  • For ApsaraDB RDS for MySQL and PolarDB for MySQL, this parameter applies only to cluster instances. If you do not specify this parameter, the details of the slow query logs of the primary node are queried by default.

  • For PolarDB-X 2.0, specify polarx_cn for compute nodes or polarx_dn for data nodes.

Type

string

No

The aggregation dimension. Valid values:

SlowLogRequestOrigin: Aggregates templates by source IP address.

OriginHost: Aggregates templates by SQL ID and filters the results by the templateID of the source host.

SlowLogRequestUser: Aggregates templates by source user.

SQL: Aggregates templates by SQL ID and filters the results by templateID.

Valid values:

  • SlowLogRequestOrigin :

    SlowLogRequestOrigin

  • OriginHost :

    OriginHost

  • SlowLogRequestUser :

    SlowLogRequestUser

  • SQL :

    SQL

TemplateId

string

No

The ID of the template.

StartTime

integer

Yes

The beginning of the time range to query. This value is a UNIX timestamp. Unit: milliseconds.

EndTime

integer

Yes

The end of the time range to query. This value is a UNIX timestamp. Unit: milliseconds.

OrderBy

string

No

The sorting method. Valid values:

Count

QueryTime

LockTime

RowsExamined

RowsSent

Asc

boolean

No

Specifies whether to sort the results in ascending order. Default value: false.

PageNumber

integer

No

The page number. Pages start from 1. Default value: 1.

PageSize

integer

No

The number of entries to return on each page. Default value: 10.

Filters

array<object>

No

The filter conditions.

object

No

The supported keys and their value formats are as follows:

hostAddress: The source IP address. Separate multiple IP addresses with commas (,).

sqlId: The SQL ID. Separate multiple SQL IDs with commas (,).

user: The user. Separate multiple users with commas (,).

dbName: The database name. Separate multiple database names with commas (,).

keyWord: The keyword. Separate multiple keywords with spaces.

tags: The tag. Separate multiple tags with commas (,).

Key

string

No

The filter parameter.

Value

string

No

The value of the filter parameter.

Response elements

Element

Type

Description

Example

object

Code

string

The HTTP status code returned.

Message

string

The returned message.

Note

If the request was successful, Successful is returned. If the request failed, an error message is returned.

RequestId

string

The request ID.

Success

string

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

Data

object

AsyncResult<DBLogRecords<SlowLogStat>>

RequestKey

string

The key of the request parameter.

ResultId

string

The ID of the result.

State

string

The status of the asynchronous request. Valid values:

-RUNNING: The request is in progress.

-SUCCESS: The request is successful.

-FAIL: The request failed.

IsFinish

boolean

Indicates whether the asynchronous request is complete.

Data

object

The data.

DbInstanceName

string

The instance ID.

NodeId

string

The node ID.

For ApsaraDB for MongoDB instances, you can use this parameter to specify a node for storage analysis. You can call the DescribeRoleZoneInfo operation to query the details of the nodes in an ApsaraDB for MongoDB instance.

  • If you specify the InsName (node ID) of the destination node, such as d-bp1872fa24d5****, the system analyzes the corresponding hidden node.

  • If you specify InsName#RoleId of the destination node, such as d-bp1872fa24d5****#299****5, the system analyzes the specified node.

Important For an ApsaraDB for MongoDB replica set instance, if you do not specify this parameter, the system analyzes the only hidden node by default. For an ApsaraDB for MongoDB sharded cluster instance, specify this parameter to select a destination node.

ItemsNumbers

integer

The number of items in the slow query log list on the current page.

StartTime

string

The start time. This value is a UNIX timestamp. Unit: milliseconds.

EndTime

string

The end time of the query. This value is a UNIX timestamp. Unit: milliseconds.

Note

The end time must be later than the start time.

DbInstanceId

integer

The numeric ID of the instance.

TotalRecords

integer

The total number of entries.

PageNumbers

integer

The page number of the paged query. Pages start from 1. Default value: 1.

MaxRecordsPerPage

integer

The maximum number of entries to return on each page of the paged query. Valid values: 5 to 100.

Logs

array<object>

The name of the object.

object

The log details.

Count

integer

The number of elements that correspond to the key.

MaxLockTime

number

This parameter is deprecated.

MaxQueryTime

number

This parameter is deprecated.

MaxRowsExamined

integer

The maximum number of scanned rows.

MaxRowsSent

integer

The maximum number of returned rows.

AvgQueryTime

number

This parameter is deprecated.

QueryTimeRate

number

The ratio of the query time.

CountRate

number

The ratio of the number of executions.

AvgRowsExamined

number

The average number of scanned rows.

OriginAlias

string

The alias of the source.

User

string

The user.

SqlTag

object

The tag.

SqlId

string

The SQL ID.

Tags

string

The tags. Multiple tags are separated by commas (,).

Comments

string

The remarks. The remarks can be 1 to 300 characters in length.

The remarks can be 1 to 300 characters in length.

Trend

array<object>

The slow log trends.

object

The slow log trends.

Timestamp

integer

The time when the task was run. This value is a UNIX timestamp. Unit: milliseconds (ms).

Value

any

The value of the filter parameter.

Database

string

The database name.

Histogram

object

The data of the trend chart.

Total

integer

The total number of entries returned for the query.

Count

array

The number of slow query logs.

integer

The number of slow query logs.

Ts

array

The timestamp of the execution.

integer

The time when the event occurred. This value is a UNIX timestamp. Unit: seconds.

TsEnd

array

This parameter is deprecated.

integer

This parameter is deprecated.

Item

array<object>

The task status.

object

The error code.

NodeId

string

The node ID.

Count

array

The number of slow query logs.

integer

The number of elements that correspond to the Key.

Rt

array

The execution time. Unit: seconds.

number

The execution time. Unit: seconds.

AvgRt

array

The average execution time.

number

The average execution time.

MaxRt

array

The maximum response time (RT). Unit: ms.

number

The maximum response time (RT). Unit: ms.

LockTime

array

The lock wait time. Unit: milliseconds.

number

The lock wait time. Unit: milliseconds.

AvgLockTime

array

The average lock wait time. Unit: seconds.

number

The average lock wait time. Unit: seconds.

MaxLockTime

array

The maximum lock wait time. Unit: seconds.

number

The maximum lock wait time. Unit: seconds.

RowsExamined

array

The total number of scanned rows.

Note

This parameter is supported by ApsaraDB RDS for MySQL, ApsaraDB RDS for PostgreSQL, and PolarDB for MySQL.

integer

The total number of scanned rows.

Note

This parameter is supported by ApsaraDB RDS for MySQL, ApsaraDB RDS for PostgreSQL, and PolarDB for MySQL.

AvgRowsExamined

array

The average number of scanned rows.

number

The average number of scanned rows.

MaxRowsExamined

array

The maximum number of scanned rows.

integer

The maximum number of scanned rows.

RowsSent

array

The number of returned rows.

integer

The number of returned rows.

AvgRowsSent

array

The average number of returned rows.

number

The average number of returned rows.

MaxRowsSent

array

The maximum number of returned rows.

integer

The maximum number of returned rows.

SqlId

string

The SQL ID.

Scheme

string

HTTP or HTTPS.

SubInstanceId

string

The ID of the child instance.

DbInstanceName

string

The instance ID.

InsName

string

The name of the shard.

AccountName

string

The database account.

HostAddress

string

The client IP address.

QueryStartTime

string

The time when the query started. The time is in the yyyy-MM-dd hh:mm:ss format and is displayed in UTC.

SQLText

string

The details of the SQL statement.

Psql

string

The SQL template.

DBName

string

The database name.

QueryTime

integer

The query execution time. Unit: milliseconds (ms).

ReturnItemNumbers

string

The number of returned items.

DocsExamined

integer

The number of documents scanned during the operation on the MongoDB instance.

KeysExamined

integer

The number of index scans on the MongoDB instance.

TableName

string

The name of the table.

LockTime

number

This parameter is deprecated.

RowsExamined

integer

The total number of scanned rows.

Note

This parameter is supported by ApsaraDB RDS for MySQL, ApsaraDB RDS for PostgreSQL, and PolarDB for MySQL.

RowsSent

integer

The number of returned rows.

ThreadId

string

The thread ID. This parameter is returned only for PolarDB for MySQL instances.

Timestamp

integer

The time when the task was run. This value is a UNIX timestamp. Unit: milliseconds (ms).

AvgLockTime

number

This parameter is deprecated.

AvgRowsSent

number

The average number of returned rows.

LockTimeSeconds

number

The lock wait time. Unit: seconds.

QueryTimeSeconds

number

The query time. Unit: seconds.

AvgLockTimeSeconds

number

The average lock wait time. Unit: seconds.

MaxLockTimeSeconds

number

The maximum lock wait time. Unit: seconds.

MaxQueryTimeSeconds

number

The maximum query time. Unit: seconds.

AvgQueryTimeSeconds

number

The average query time. Unit: seconds.

SqlType

string

The type of the SQL statement.

QueryId

string

The query ID.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

NodeType

string

The node type.

Note

This parameter is supported by ApsaraDB for MongoDB and Tair (Redis OSS-compatible).

HostInsId

string

The ID of the host instance.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

InsRole

string

The instance role.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

OpType

string

The operation type.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

Namespace

string

The namespace.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

AvgKeysExamined

number

The average number of index scans.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

AvgDocExamined

number

The average number of scanned documents.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

AvgReturnNum

number

The average number of returned rows.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

MaxKeysExamined

integer

The maximum number of index scans.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

MaxDocExamined

integer

The maximum number of scanned documents.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

MaxReturnNum

integer

The maximum number of returned rows.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

ReturnNum

integer

The number of returned rows.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

DocExamined

integer

The number of scanned documents.

Note

This parameter is supported only by ApsaraDB for MongoDB instances.

Command

string

The slow query statement.

Note

This parameter is supported only by Tair (Redis OSS-compatible) instances.

IOWrites

integer

The number of I/O writes.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

MaxIOWrites

integer

The maximum number of I/O writes.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

LastRowsCountAffected

integer

The number of rows affected by the last SQL statement.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

MaxLastRowsCountAffected

integer

The maximum number of rows affected by the last SQL statement.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

LogicalIOReads

integer

The number of logical reads.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

MaxLogicalIOReads

integer

The maximum number of logical reads.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

PhysicalIOReads

integer

The number of physical reads.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

MaxPhysicalIOReads

integer

The maximum number of physical reads.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

RowsCountAffected

integer

The number of affected rows.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

MaxRowsCountAffected

integer

The maximum number of affected rows.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

CPUTime

number

This parameter is deprecated.

AvgCPUTime

number

This parameter is deprecated.

MaxCPUTime

number

This parameter is deprecated.

AvgIOWrites

number

The average number of I/O writes.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

AvgLastRowsCountAffected

number

The average number of rows affected by the last SQL statement.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

AvgLogicalIOReads

number

The average number of logical reads.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

AvgPhysicalIOReads

number

The average number of physical reads.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

AvgRowsCountAffected

number

The average number of affected rows.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

AvgCPUTimeSeconds

number

The average CPU query time. Unit: seconds.

MaxCPUTimeSeconds

number

The longest CPU query time. Unit: seconds.

CPUTimeSeconds

number

The CPU query time. Unit: seconds.

Note

This parameter is supported only by ApsaraDB RDS for SQL Server instances.

Rows

integer

The total number of rows updated or returned by the compute nodes of the PolarDB-X 2.0 instance.

Note

This parameter is supported only by PolarDB-X 2.0 instances.

AvgRows

number

The average number of rows.

MaxRows

integer

The maximum number of rows.

Frows

integer

The number of rows pulled by the compute nodes (CNs) of the PolarDB-X 2.0 instance.

Note

This parameter is supported only by PolarDB-X 2.0 instances.

AvgFrows

number

The average number of pulled rows.

MaxFrows

integer

The maximum number of pulled rows.

Scnt

integer

The number of requests sent from the compute nodes (CNs) to data nodes (DNs) in the PolarDB-X 2.0 instance.

Note

This parameter is supported only by PolarDB-X 2.0 instances.

AvgScnt

number

The average number of requests.

MaxScnt

integer

The maximum number of requests.

RuleId

string

The ID of the rule. For more information, see Query administration.

AvgRt

number

MaxRt

number

AvgRequestSize

number

MaxRequestSize

number

AvgResponseSize

number

MaxResponseSize

number

TotalCount

integer

Cmd

string

ClientIp

string

DbId

string

ErrorCode

integer

The error code.

Message

string

The error message.

Timestamp

integer

The timestamp of the request.

Examples

Success response

JSON format

{
  "Code": "",
  "Message": "",
  "RequestId": "",
  "Success": "",
  "Data": {
    "RequestKey": "",
    "ResultId": "",
    "State": "",
    "IsFinish": true,
    "Data": {
      "DbInstanceName": "",
      "NodeId": "",
      "ItemsNumbers": 0,
      "StartTime": "",
      "EndTime": "",
      "DbInstanceId": 0,
      "TotalRecords": 0,
      "PageNumbers": 0,
      "MaxRecordsPerPage": 0,
      "Logs": [
        {
          "Count": 0,
          "MaxLockTime": 0,
          "MaxQueryTime": 0,
          "MaxRowsExamined": 0,
          "MaxRowsSent": 0,
          "AvgQueryTime": 0,
          "QueryTimeRate": 0,
          "CountRate": 0,
          "AvgRowsExamined": 0,
          "OriginAlias": "",
          "User": "",
          "SqlTag": {
            "SqlId": "",
            "Tags": "",
            "Comments": ""
          },
          "Trend": [
            {
              "Timestamp": 0,
              "Value": ""
            }
          ],
          "Database": "",
          "Histogram": {
            "Total": 0,
            "Count": [
              0
            ],
            "Ts": [
              0
            ],
            "TsEnd": [
              0
            ],
            "Item": [
              {
                "NodeId": "",
                "Count": [
                  0
                ]
              }
            ],
            "Rt": [
              0
            ],
            "AvgRt": [
              0
            ],
            "MaxRt": [
              0
            ],
            "LockTime": [
              0
            ],
            "AvgLockTime": [
              0
            ],
            "MaxLockTime": [
              0
            ],
            "RowsExamined": [
              0
            ],
            "AvgRowsExamined": [
              0
            ],
            "MaxRowsExamined": [
              0
            ],
            "RowsSent": [
              0
            ],
            "AvgRowsSent": [
              0
            ],
            "MaxRowsSent": [
              0
            ]
          },
          "SqlId": "",
          "Scheme": "",
          "SubInstanceId": "",
          "DbInstanceName": "",
          "InsName": "",
          "AccountName": "",
          "HostAddress": "",
          "QueryStartTime": "",
          "SQLText": "",
          "Psql": "",
          "DBName": "",
          "QueryTime": 0,
          "ReturnItemNumbers": "",
          "DocsExamined": 0,
          "KeysExamined": 0,
          "TableName": "",
          "LockTime": 0,
          "RowsExamined": 0,
          "RowsSent": 0,
          "ThreadId": "",
          "Timestamp": 0,
          "AvgLockTime": 0,
          "AvgRowsSent": 0,
          "LockTimeSeconds": 0,
          "QueryTimeSeconds": 0,
          "AvgLockTimeSeconds": 0,
          "MaxLockTimeSeconds": 0,
          "MaxQueryTimeSeconds": 0,
          "AvgQueryTimeSeconds": 0,
          "SqlType": "",
          "QueryId": "",
          "NodeType": "",
          "HostInsId": "",
          "InsRole": "",
          "OpType": "",
          "Namespace": "",
          "AvgKeysExamined": 0,
          "AvgDocExamined": 0,
          "AvgReturnNum": 0,
          "MaxKeysExamined": 0,
          "MaxDocExamined": 0,
          "MaxReturnNum": 0,
          "ReturnNum": 0,
          "DocExamined": 0,
          "Command": "",
          "IOWrites": 0,
          "MaxIOWrites": 0,
          "LastRowsCountAffected": 0,
          "MaxLastRowsCountAffected": 0,
          "LogicalIOReads": 0,
          "MaxLogicalIOReads": 0,
          "PhysicalIOReads": 0,
          "MaxPhysicalIOReads": 0,
          "RowsCountAffected": 0,
          "MaxRowsCountAffected": 0,
          "CPUTime": 0,
          "AvgCPUTime": 0,
          "MaxCPUTime": 0,
          "AvgIOWrites": 0,
          "AvgLastRowsCountAffected": 0,
          "AvgLogicalIOReads": 0,
          "AvgPhysicalIOReads": 0,
          "AvgRowsCountAffected": 0,
          "AvgCPUTimeSeconds": 0,
          "MaxCPUTimeSeconds": 0,
          "CPUTimeSeconds": 0,
          "Rows": 0,
          "AvgRows": 0,
          "MaxRows": 0,
          "Frows": 0,
          "AvgFrows": 0,
          "MaxFrows": 0,
          "Scnt": 0,
          "AvgScnt": 0,
          "MaxScnt": 0,
          "RuleId": "",
          "AvgRt": 0,
          "MaxRt": 0,
          "AvgRequestSize": 0,
          "MaxRequestSize": 0,
          "AvgResponseSize": 0,
          "MaxResponseSize": 0,
          "TotalCount": 0,
          "Cmd": "",
          "ClientIp": "",
          "DbId": ""
        }
      ]
    },
    "ErrorCode": 0,
    "Message": "",
    "Timestamp": 0
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid.
403 NoPermission You are not authorized to do this action.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.