All Products
Search
Document Center

PolarDB:DescribeSlowLogRecords

最終更新日:Nov 17, 2025

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 the available regions and their IDs for your account.

cn-hangzhou

DBClusterId

string

Yes

The cluster ID.

Note

You can call the DescribeDBClusters operation to query information about all clusters in a region, including cluster IDs.

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

NodeId

string

No

The node ID.

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

StartTime

string

Yes

The beginning of the time range to query. Specify the time in the YYYY-MM-DDThh:mmZ format. The time must be in UTC.

Note
  • You can query data from the last 30 days.

  • This parameter is specified in UTC. If your service is in a different time zone, convert the time accordingly. For example, if your service is in the UTC+8 time zone and you want to query slow query logs from 08:00 to 12:00 (UTC+8), set the start and end times to 00:00 and 04:00 (UTC).

2022-11-15T16:00Z

EndTime

string

Yes

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

Note

This parameter is specified in UTC. If your service is in a different time zone, convert the time accordingly. For example, if your service is in the UTC+8 time zone and you want to query slow query logs from 08:00 to 12:00 (UTC+8), set the start and end times to 00:00 and 04:00 (UTC).

2022-11-16T04:00Z

DBName

string

No

The name of the database.

testdb

PageSize

integer

No

The number of entries to return on each page. Valid values:

  • 30

  • 50

  • 100

Default value: 30.

30

PageNumber

integer

No

The page number. The value must be an integer that is greater than 0. The value cannot exceed the maximum value of the Integer data type.

Default value: 1.

1

SQLHASH

string

No

The unique identifier of the SQL statement. You can use this identifier to query the details of the slow SQL 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>

A list of slow query log details.

object

DBName

string

The name of the database.

testdb

DBNodeId

string

The node ID.

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

ExecutionStartTime

string

The time when the SQL statement started to be executed. The time is in the YYYY-MM-DDThh:mmZ format. The time is displayed in UTC.

2021-04-07T03:47Z

HostAddress

string

The address of the client that is connected to the database.

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

LockTimes

integer

The lock duration of the SQL statement. Unit: seconds.

0

ParseRowCounts

integer

The number of parsed rows.

0

QueryTimeMS

integer

The query duration. Unit: milliseconds.

100

QueryTimes

integer

The execution duration of the SQL statement. Unit: seconds.

20

ReturnRowCounts

integer

The number of returned rows.

0

SQLHash

string

The unique identifier of the SQL statement.

U2FsdGVk****

SQLText

string

The SQL statement.

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

PageNumber

integer

The page number.

1

PageRecordCount

integer

The number of entries on the current page.

1

RequestId

string

The request ID.

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

TotalRecordCount

integer

The total number of SQL statements.

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)"
      }
    ]
  },
  "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.