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

This operation is supported by only PolarDB for MySQL clusters.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No DescribeSlowLogRecords

The operation that you want to perform. Set the value to DescribeSlowLogRecords.

DBClusterId String Yes pc-************

The ID of the cluster.

Note You can call the DescribeDBClusters operation to query information about all clusters that are deployed in a specified region, such as the cluster ID.
RegionId String Yes cn-hangzhou

The ID of the region.

Note You can call the DescribeRegions operation to query all regions that are available within your account, such as the region ID.
StartTime String Yes 2021-04-01T16:00Z

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

Note You can specify a time range of at most 30 days.
EndTime String Yes 2021-04-07T04:00Z

The end of the time range to query. Specify the time in the ISO 8601 standard in the YYYY-MM-DDThh:mmZ format. The time must be in UTC. The end time must be later than the beginning time. The maximum time range that can be specified is 24 hours.

DBName String No testdb

The name of the database.

PageSize Integer No 30

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

  • 30
  • 50
  • 100

Default value: 30

PageNumber Integer No 1

The number of the page to return. The value must be an integer that is larger than 0.

Default value: 1.

SQLHASH String No U2FsdGVk****

The unique ID of an SQL statement in the slow query log, which is used to query the details of the slow query logs of the SQL statement.

Response parameters

Parameter Type Example Description
Items Array of SQLSlowRecord

The details of slow query logs.

SQLSlowRecord
DBName String testdb

The name of the database.

DBNodeId String pi-*****************

The ID of the node.

ExecutionStartTime String 2021-04-07T03:47:24Z

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

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

The IP address of the client that is used to connect to the database.

LockTimes Long 0

The duration during which the SQL statement was locked. Unit: seconds.

ParseRowCounts Long 0

The number of parsed rows.

QueryTimes Long 20

The amount of time that was consumed to execute the SQL statement. Unit: seconds.

ReturnRowCounts Long 0

The number of returned rows.

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

The query statements.

TotalRecordCount Integer 1

The total number of SQL statements.

PageNumber Integer 1

The page number of the returned page.

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

The ID of the request.

DBClusterId String pc-*****************

The ID of the cluster.

Engine String polardb_mysql

The engine of the database.

PageRecordCount Integer 1

The number of entries returned on the current page.

Examples

Sample requests

http(s)://polardb.aliyuncs.com/?Action=DescribeSlowLogRecords
&DBClusterId=pc-************
&RegionId=cn-hangzhou
&StartTime=2019-11-18T16:00Z
&EndTime=2019-12-18T16:00Z
&<Common Request Parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

For a list of error codes, visit the API Error Center.