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

You can call this operation for only the clusters of PolarDB for MySQL 5.6, 5.7, or 8.0.

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.

RegionId String Yes cn-hangzhou

The ID of the region.

Note You can call the DescribeRegions operation to query available regions.
StartTime String Yes 2020-11-12T16:00Z

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

EndTime String Yes 2020-11-13T09:00Z

The end of the time range to query. The end time must be later than the start time. The maximum time range that can be specified is 31 days. Specify the time in the YYYY-MM-DDThh:mmZ format. The time must be in UTC.

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 a positive integer and cannot exceed the maximum value of the Integer parameter.

Default value: 1

SQLHASH String No U2FsdGVk****

The unique ID of the SQL statement in the statistics of slow query logs. You can use the unique ID to query the details about 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 test_db

The name of the database.

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

The ID of the node.

ExecutionStartTime String 2020-11-13T08:05:24Z

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.

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

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

LockTimes Long 0

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

ParseRowCounts Long 0

The number of parsed rows.

QueryTimes Long 20

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

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 C77EF623-844B-48A1-A3B9-78F841******

The ID of the request.

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

The ID of the cluster.

Engine String polardb_mysql

The database engine.

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>C77EF623-844B-48A1-A3B9-78F841******</RequestId>
  <PageNumber>1</PageNumber>
  <DBClusterId>pc-*****************</DBClusterId>
  <Items>
        <SQLSlowRecord>
              <QueryTimes>20</QueryTimes>
              <ExecutionStartTime>2020-11-13T08:05:24Z</ExecutionStartTime>
              <ReturnRowCounts>1</ReturnRowCounts>
              <LockTimes>0</LockTimes>
              <DBName>test_db</DBName>
              <ParseRowCounts>0</ParseRowCounts>
              <DBNodeId>pi-*****************</DBNodeId>
              <HostAddress>test_api[test_api] @  [100. ***. ***. ***]</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": "C77EF623-844B-48A1-A3B9-78F841******",
    "PageNumber": 1,
    "DBClusterId": "pc-*****************",
    "Items": {
        "SQLSlowRecord": [
            {
                "QueryTimes": 20,
                "ExecutionStartTime": "2020-11-13T08:05:24Z",
                "ReturnRowCounts": 1,
                "LockTimes": 0,
                "DBName": "test_db",
                "ParseRowCounts": 0,
                "DBNodeId": "pi-*****************",
                "HostAddress": "test_api[test_api] @  [100. ***. ***. ***]",
                "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.