All Products
Search
Document Center

PolarDB:DescribeSlowLogRecords

Last Updated:Apr 10, 2026

Queries the details of slow query logs for a PolarDB cluster.

Operation description

Note

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

polardb:DescribeSlowLogRecords

get

*dbcluster

acs:polardb:{#regionId}:{#accountId}:dbcluster/{#dbclusterId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

Note

You can call the DescribeRegions operation to query available regions and their region IDs.

cn-hangzhou

DBClusterId

string

Yes

The cluster ID.

Note

You can call the DescribeDBClusters operation to query all clusters in the target region and their cluster IDs.

pc-************

NodeId

string

No

The node ID.

pi-**********

StartTime

string

Yes

The start of the query time range. Specify the time in UTC in the YYYY-MM-DDThh:mmZ format.

Note
  • You can query slow query logs from the past 30 days.

  • The time must be in UTC. If your service is in a different time zone, you must convert the time. For example, to query data from 08:00 to 12:00 in the UTC+8 time zone, you must set the time range from 00:00 UTC to 04:00 UTC.

2022-11-15T16:00Z

EndTime

string

Yes

The end of the query time range. The end time must be later than the start time. The time range cannot exceed 24 hours. Specify the time in UTC in the YYYY-MM-DDThh:mmZ format.

Note

The time must be in UTC. If your service is in a different time zone, you must convert the time. For example, to query data from 08:00 to 12:00 in the UTC+8 time zone, you must set the time range from 00:00 UTC to 04:00 UTC.

2022-11-16T04:00Z

DBName

string

No

The database name.

testdb

PageSize

integer

No

The number of records per page. Valid values:

  • 30

  • 50

  • 100

Default value: 30.

30

PageNumber

integer

No

The page number. The value must be an integer greater than 0.

Default value: 1.

1

SQLHASH

string

No

The SQL hash of a slow query. Obtain this hash from slow query log statistics to retrieve the details of a specific slow query.

U2FsdGVk****

Description

Response elements

Element

Type

Description

Example

object

DBClusterId

string

The cluster ID.

pc-*****************

Engine

string

The database engine.

polardb_mysql

Items

object

SQLSlowRecord

array<object>

The slow query log records.

object

DBName

string

The name of the database.

testdb

DBNodeId

string

The node ID.

pi-*****************

ExecutionStartTime

string

The execution start time of the SQL statement. The time is in YYYY-MM-DDThh:mmZ format (UTC).

2021-04-07T03:47Z

HostAddress

string

The client address.

testdb[testdb] @ [100.**.**.242]

LockTimes

integer

The lock duration, in seconds.

0

ParseRowCounts

integer

The number of parsed rows.

0

QueryTimeMS

integer

The query duration, in milliseconds.

100

QueryTimes

integer

The execution duration, in seconds.

20

ReturnRowCounts

integer

The number of returned rows.

0

SQLHash

string

The unique identifier for the SQL statement.

U2FsdGVk****

SQLText

string

The SQL statement.

/* Query from *** by user 111 */ SELECT sleep(20)

LockTimeMS

integer

The lock duration, in milliseconds.

100

PageNumber

integer

The page number.

1

PageRecordCount

integer

The number of records on the current page.

1

RequestId

string

The request ID.

A7E6A8FD-C50B-46B2-BA85-D8B8D3******

TotalRecordCount

integer

The total number of records.

1

description

Examples

Success response

JSON format

{
  "DBClusterId": "pc-*****************",
  "Engine": "polardb_mysql",
  "Items": {
    "SQLSlowRecord": [
      {
        "DBName": "testdb",
        "DBNodeId": "pi-*****************",
        "ExecutionStartTime": "2021-04-07T03:47Z",
        "HostAddress": "testdb[testdb] @  [100.**.**.242]",
        "LockTimes": 0,
        "ParseRowCounts": 0,
        "QueryTimeMS": 100,
        "QueryTimes": 20,
        "ReturnRowCounts": 0,
        "SQLHash": "U2FsdGVk****",
        "SQLText": "/* Query from *** by user 111 */ SELECT sleep(20)",
        "LockTimeMS": 100
      }
    ]
  },
  "PageNumber": 1,
  "PageRecordCount": 1,
  "RequestId": "A7E6A8FD-C50B-46B2-BA85-D8B8D3******",
  "TotalRecordCount": 1
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidStartTime.Malformed The specified parameter StartTime is not valid. The specified StartTime parameter is invalid.
404 InvalidDBClusterId.NotFound The DBInstanceId provided does not exist in our records. The specified DBClusterId parameter does not exist in the current record.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.