All Products
Search
Document Center

PolarDB:DescribeSlowLogs

Last Updated:Apr 17, 2026

Queries the slow query log statistics 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:DescribeSlowLogs

get

*dbcluster

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

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

cn-hangzhou

DBClusterId

string

Yes

The cluster ID.

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

StartTime

string

Yes

The start date of the query range. The date can be up to 31 days in the past. Specify the date in yyyy-MM-ddZ format. The time is in UTC.

2021-05-01Z

EndTime

string

Yes

The end date of the query range. The end date cannot be earlier than the start date, and the interval between the start and end dates cannot exceed 31 days. Specify the date in yyyy-MM-ddZ format. The time is in UTC.

2021-05-30Z

DBName

string

No

The database name.

PolarDB_MySQL

PageSize

integer

No

The number of logs to return on each page. Valid values: 30 to 100. The default value is 30.

30

PageNumber

integer

No

The page number.

The default value is 1.

1

Response elements

Element

Type

Description

Example

object

TotalRecordCount

integer

The total number of records.

5

PageRecordCount

integer

The number of SQL statements on the current page.

6

EndTime

string

The end time of the query.

2021-05-30Z

RequestId

string

The request ID.

2553A660-E4EB-4AF4-A402-8AFF70A49143

PageNumber

integer

The page number.

3

StartTime

string

The start time of the query.

2021-05-01Z

DBClusterId

string

The cluster ID.

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

Items

object

SQLSlowLog

array<object>

Details of slow query logs.

object

SQLText

string

The SQL statement.

select id,name from tb_table

ReturnMaxRowCount

integer

The maximum number of returned rows.

3

CreateTime

string

The time when the slow query log was generated.

2021-05-30Z

MaxExecutionTime

integer

The maximum execution time. Unit: seconds.

60

ParseTotalRowCounts

integer

The total number of scanned rows.

2

TotalLockTimes

integer

The total lock duration. Unit: seconds.

1

TotalExecutionTimes

integer

The total execution time. Unit: seconds.

2

DBNodeId

string

The node ID.

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

SQLHASH

string

The unique ID of the SQL statement. You can use this ID to obtain the details of the slow query.

U2FsdGVkxxxx

ParseMaxRowCount

integer

The maximum number of scanned rows.

1

MaxLockTime

integer

The maximum lock duration. Unit: seconds.

1

ReturnTotalRowCounts

integer

The total number of returned rows.

1

DBName

string

The database name.

PolarDB_MySQL

TotalExecutionCounts

integer

The total number of executions.

2

MaxExecutionTimeMs

string

The maximum execution time. Unit: milliseconds.

60000

Engine

string

The database engine.

polardb_mysql

Examples

Success response

JSON format

{
  "TotalRecordCount": 5,
  "PageRecordCount": 6,
  "EndTime": "2021-05-30Z",
  "RequestId": "2553A660-E4EB-4AF4-A402-8AFF70A49143",
  "PageNumber": 3,
  "StartTime": "2021-05-01Z",
  "DBClusterId": "pc-****************",
  "Items": {
    "SQLSlowLog": [
      {
        "SQLText": "select id,name from tb_table",
        "ReturnMaxRowCount": 3,
        "CreateTime": "2021-05-30Z",
        "MaxExecutionTime": 60,
        "ParseTotalRowCounts": 2,
        "TotalLockTimes": 1,
        "TotalExecutionTimes": 2,
        "DBNodeId": "pi-***************",
        "SQLHASH": "U2FsdGVkxxxx",
        "ParseMaxRowCount": 1,
        "MaxLockTime": 1,
        "ReturnTotalRowCounts": 1,
        "DBName": "PolarDB_MySQL",
        "TotalExecutionCounts": 2,
        "MaxExecutionTimeMs": "60000"
      }
    ]
  },
  "Engine": "polardb_mysql"
}

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.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.