DescribeSlowLogRecords

Updated at:

Queries slow query log records of a database instance. You can filter and sort the results by multiple conditions.

Operation description

  • InstanceId is the instance ID. This parameter is required.

  • StartTime and EndTime specify the time range for the query. These parameters are required.

  • Settings PageNumber and PageSize to retrieve results by paging.

  • Use the OrderBy parameter to sort the results. For more information about the sortable fields, refer to the References.

  • Use the Filters parameter to further refine query conditions, such as filtering by host address or SQL ID.
    Important Certain database types, such as PostgreSQL and PolarDB for PostgreSQL, do not support specific sorting methods. Select appropriate parameters based on your database type.

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

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The instance ID.

rm-8vbk4xz99su8****

NodeId

string

No

The node ID.

pi-d9j9fe7wq7t9i****

StartTime

integer

Yes

The start time.

1596177993000

EndTime

integer

Yes

The end time.

1634972640000

PageNumber

integer

No

The page number. Pages start from page 1.

1

PageSize

integer

No

The number of entries per page.

10

Filters

array<object>

No

The list of filter conditions.

object

No

The list of filter conditions.

Key

string

No

The filter parameter.

Note

For more information, refer to the supplementary description.

None

Value

string

No

The value of the filter parameter.

None

OrderBy

string

No

  • Common to all engines

    • QueryTimeSeconds: query duration (seconds).

    • Timestamp: timestamp.

  • SQL-based engines (MySQL / PolarDB for MySQL / PostgreSQL / PolarDB for PostgreSQL / PolarDB for Oracle / PolarDB-X DN)

    • LockTimeSeconds: lock time (seconds).

    • RowsExamined: rows examined.

    • RowsSent: rows returned.

  • MongoDB

    • KeysExamined: number of indexes scanned.

    • DocExamined: number of documents scanned.

    • ReturnNum: rows returned.

  • SQL Server

    • CPUTimeSeconds: CPU time.

    • IOWrites: number of I/O writes.

    • LastRowsCountAffected: last rows affected.

    • LogicalIOReads: logical I/O reads.

    • PhysicalIOReads: physical I/O reads.

    • RowsCountAffected: rows affected.

  • PolarDB-X CN

    • RowsSent: rows returned or updated.

    • Frows: rows fetched.

    • Scnt: number of physical SQL statements.

QueryTimeSeconds

Asc

boolean

No

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

  • true: Sort in ascending order.

  • false: Sort in descending order.

true

Supported parameters and values for Key:

  • ApsaraDB RDS for MySQL, PolarDB for MySQL, ApsaraDB RDS for PostgreSQL, and PolarDB for PostgreSQL
    • hostAddress: the source address. Separate multiple values with commas (,).

    • sqlId: the SQL ID. Separate multiple values with commas (,).

    • user: the username. Separate multiple values with commas (,).

    • dbName: the database name. Separate multiple values with commas (,).

    • tags: the tags. Separate multiple values with commas (,).

  • MongoDB
    • hostInsId: the role ID. Separate multiple values with commas (,).

    • insRole: the instance role. Separate multiple values with commas (,).

    • opType: the operation type. Separate multiple values with commas (,).

    • namespace: the namespace. Separate multiple values with commas (,).

    • nodeType: the component type. Separate multiple values with commas (,).

    • queryId: the query ID. Separate multiple values with commas (,).

  • Tair (Redis® OSS-Compatible)
    • hostAddress: the source address.

    • user: the username.

    • dbName: the database name.

    • nodeType: the node type.

  • ApsaraDB RDS for SQL Server
    • hostAddress: the source address. Separate multiple values with commas (,).

    • sqlId: the SQL ID. Separate multiple values with commas (,).

    • user: the username. Separate multiple values with commas (,).

    • dbName: the database name. Separate multiple values with commas (,).

    • tags: the tags. Separate multiple values with commas (,).

  • PolarDB-X
    • traceId: the trace ID of the instance.

    • role: the node role. Valid values: CN (compute node) and DN (storage node). This parameter is required.

    • hostAddress: the source address. Separate multiple values with commas (,).

    • sqlId: the SQL ID. Separate multiple values with commas (,).

    • user: the username. Separate multiple values with commas (,).

    • dbName: the database name. Separate multiple values with commas (,).

    • tags: the tags. Separate multiple values with commas (,).

Note
  • SQL engines support querying data by sqlId. You can pass multiple sqlId values separated by commas (,), up to 20.

  • MongoDB supports querying data by queryId. You can pass multiple queryId values separated by commas (,), up to 20.

Response elements

Element

Type

Description

Example

object

Code

string

The status code returned.

200

Message

string

The message returned for the request.

Note

This parameter returns Successful when the request succeeds. If the request fails, an exception message is returned, such as an error code.

Successful

RequestId

string

The request ID.

A1C79EE2-D04D-571B-8C60-961FAF8E****

Success

string

Indicates whether the request was successful.

  • true: The request was successful.

  • false: The request failed.

true

Data

object

DBLogRecords

DbInstanceName

string

The instance ID.

rm-bp157g54vy772****

NodeId

string

The node ID.

node123

ItemsNumbers

integer

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

10

StartTime

string

The start time.

1672531200000

EndTime

string

The end time.

1672617600000

DbInstanceId

integer

The numeric ID of the instance.

100

TotalRecords

integer

The total number of records.

100

PageNumbers

integer

The page number for the paged query. The value starts from 1. Default value: 1.

1

MaxRecordsPerPage

integer

The maximum number of records per page for the paged query. Valid values: 5 to 100.

20

Logs

array<object>

The returned data.

array<object>

The returned data.

SqlId

string

The SQL template ID.

sqlId

Scheme

string

The data schema.

HTTPS

SubInstanceId

string

The sub-instance ID.

r-8vb219d10038****

DbInstanceName

string

The instance ID.

rm-2zebg30mk056g****

InsName

string

The instance name.

test

AccountName

string

The username.

user1

HostAddress

string

The source address.

192.168.1.1

QueryStartTime

string

The time when the query started. Format: yyyy-MM-dd hh:mm:ss (UTC).

2024-04-01 11:00:00

SQLText

string

The SQL text.

SELECT * FROM my_table WHERE ROWNUM <= 10

Psql

string

The SQL template.

SELECT * FROM my_table WHERE ROWNUM <= 10

DBName

string

The database name.

test

QueryTime

integer

The query duration.

121

ReturnItemNumbers

string

The number of returned items.

test

DocsExamined

string

The number of documents scanned during the MongoDB operation.

100

KeysExamined

string

The number of index rows scanned in MongoDB.

valueA

TableName

string

The table name.

tableNameExample

LockTime

number

The lock wait time.

100

RowsExamined

integer

The number of rows scanned.

100

RowsSent

integer

The number of rows returned.

10

ThreadId

string

The thread ID.

57472578

Timestamp

integer

The timestamp.

1747118812

SqlTag

object

The tag.

SqlId

string

sqlid。

8ad7069f236bcdaaa9b3ae4b6299****

Tags

string

Multiple tags separated by commas.

DAS_IMPORTANT,DAS_IN_PLAN

Comments

string

The remarks.

test

LockTimeSeconds

number

The lock wait time, in seconds.

100

QueryTimeSeconds

number

The query duration, in seconds.

100

SqlType

string

The type of the SQL statement. Valid values:

  • SELECT

  • UPDATE

  • DELETE

SELECT

CPUTime

number

The CPU query time.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

50

IOWrites

integer

The number of I/O writes.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

1

LastRowsCountAffected

integer

The number of rows affected by the last statement.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

10

LogicalIOReads

integer

The number of logical reads.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

1

PhysicalIOReads

integer

The number of physical reads.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

1

RowsCountAffected

integer

The number of rows affected.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

10

Command

string

The slow query statement.

Note

Only ApsaraDB Tair (Redis® OSS-Compatible) database instances are supported.

GET async_c4d163675f44fe83f6214cf9ba5exxxx

Namespace

string

The namespace.

Note

Only ApsaraDB for MongoDB instances are supported.

app.event

QueryId

string

The query ID.

Note

Only ApsaraDB for MongoDB instances are supported.

d236d0c4ae8485f6ffe5fdbe5e1bdxxx

ReturnNum

string

The number of rows returned.

Note

Only ApsaraDB for MongoDB instances are supported.

20

ApplicationName

string

The application name.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

MyApp

CPUTimeSeconds

number

The CPU query time, in seconds.

Note

Only ApsaraDB RDS for SQL Server instances are supported.

100

Rows

integer

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

Note

Only ApsaraDB PolarDB-X 2.0 database instances are supported.

20

Frows

integer

The number of rows fetched by the compute node (CN) of the PolarDB-X 2.0 database.

Note

Only ApsaraDB PolarDB-X 2.0 database instances are supported.

10

Scnt

integer

The number of data node (DN) requests from the compute node (CN) of the PolarDB-X 2.0 database.

Note

Only ApsaraDB PolarDB-X 2.0 database instances are supported.

10

TraceId

string

The trace ID of PolarDB-X 2.0, which is the execute ID of the SQL statement on the database data node.

Note

Only ApsaraDB PolarDB-X 2.0 database instances are supported.

074ce334-5247-40b9-b0c1-158aea5d****

TemplateId

string

The template ID of the PolarDB-X 2.0 database.

Note

Only ApsaraDB PolarDB-X 2.0 database instances are supported.

6a63b6ac4572abfaef7d1163f684****

NodeId

string

The node ID.

r-uf6cfc5e1xxx-proxy-11

Cmd

string

The command executed at the Redis proxy layer.

GET

Rt

integer

The total response time at the Redis proxy layer, in microseconds.

2055

RequestSize

integer

The request packet size at the Redis proxy layer, in bytes.

58

ResponseSize

integer

The response packet size at the Redis proxy layer, in bytes.

1535916

ClientIp

string

The client IP address connected to the Redis proxy.

172.16.15.204

DbId

string

Redis Proxy DbId

r-uf6cfc5e1bcb1xxx-db-5

OriginTime

string

The execution time at the Redis proxy.

2026-09-18 10:54:55.311

OpType

string

The operation type.

Note

Only ApsaraDB for MongoDB instances are supported.

getMore

Fail

string

Indicates whether the SQL execution was successful. 0 indicates success. A non-zero value indicates failure.

Note

Only ApsaraDB for Lindorm instances are supported.

1

Params

string

The parameter values attached to the SQL statement in parameter query scenarios. Multiple parameters are separated by commas (,).

Note

Only ApsaraDB for Lindorm database instances are supported.

Reason

string

The error message when the slow query execution fails.

Note

Only ApsaraDB for Lindorm instances are supported.

create-by-mse-can-not-delete

ReqId

string

The unique identifier of the slow query log record.

Note

Only ApsaraDB for Lindorm instances are supported.

hotspot-request-001

ExtText

string

The extension field that contains additional information about the SQL execution.

Note

Only PolarDB for MySQL instances are supported.

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "Successful",
  "RequestId": "A1C79EE2-D04D-571B-8C60-961FAF8E****",
  "Success": "true",
  "Data": {
    "DbInstanceName": "rm-bp157g54vy772****",
    "NodeId": "node123",
    "ItemsNumbers": 10,
    "StartTime": "1672531200000",
    "EndTime": "1672617600000",
    "DbInstanceId": 100,
    "TotalRecords": 100,
    "PageNumbers": 1,
    "MaxRecordsPerPage": 20,
    "Logs": [
      {
        "SqlId": "sqlId",
        "Scheme": "HTTPS",
        "SubInstanceId": "r-8vb219d10038****",
        "DbInstanceName": "rm-2zebg30mk056g****",
        "InsName": "test",
        "AccountName": "user1",
        "HostAddress": "192.168.1.1",
        "QueryStartTime": "2024-04-01 11:00:00",
        "SQLText": "SELECT * FROM my_table WHERE ROWNUM <= 10",
        "Psql": "SELECT * FROM my_table WHERE ROWNUM <= 10\n",
        "DBName": "test",
        "QueryTime": 121,
        "ReturnItemNumbers": "test",
        "DocsExamined": "100",
        "KeysExamined": "valueA",
        "TableName": "tableNameExample",
        "LockTime": 100,
        "RowsExamined": 100,
        "RowsSent": 10,
        "ThreadId": "57472578",
        "Timestamp": 1747118812,
        "SqlTag": {
          "SqlId": "8ad7069f236bcdaaa9b3ae4b6299****",
          "Tags": "DAS_IMPORTANT,DAS_IN_PLAN",
          "Comments": "test"
        },
        "LockTimeSeconds": 100,
        "QueryTimeSeconds": 100,
        "SqlType": "SELECT",
        "CPUTime": 50,
        "IOWrites": 1,
        "LastRowsCountAffected": 10,
        "LogicalIOReads": 1,
        "PhysicalIOReads": 1,
        "RowsCountAffected": 10,
        "Command": "SELECT",
        "Namespace": "pro-test",
        "QueryId": "sq-1pzcdMwRb",
        "ReturnNum": "20",
        "ApplicationName": "MyApp",
        "CPUTimeSeconds": 100,
        "Rows": 20,
        "Frows": 10,
        "Scnt": 10,
        "TraceId": "074ce334-5247-40b9-b0c1-158aea5d****",
        "TemplateId": "6a63b6ac4572abfaef7d1163f684****",
        "NodeId": "r-uf6cfc5e1xxx-proxy-11",
        "Cmd": "GET",
        "Rt": 2055,
        "RequestSize": 58,
        "ResponseSize": 1535916,
        "ClientIp": "172.16.15.204",
        "DbId": "r-uf6cfc5e1bcb1xxx-db-5",
        "OriginTime": "2026-09-18 10:54:55.311",
        "OpType": "getMore",
        "Fail": "1",
        "Params": "",
        "Reason": "create-by-mse-can-not-delete",
        "ReqId": "hotspot-request-001",
        "ExtText": ""
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid. The request parameters are invalid.
403 NoPermission You are not authorized to do this action. You do not have the permission to perform this operation.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.