You can call this operation to query log statistics about slow queries for an ApsaraDB for PolarDB cluster.

When you call this operation, make sure that the database engine of the specified cluster is MySQL 5.6 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 DescribeSlowLogs The operation that you want to perform. Set the value to DescribeSlowLogs.
DBClusterId String Yes pc-bp1w2u4xxxxxxxxxx The ID of the ApsaraDB for PolarDB cluster to be queried.
RegionId String Yes cn-hangzhou The region ID of the ApsaraDB for PolarDB cluster to be queried.
Note You can call the DescribeRegions operation to query the most recent region list.
StartTime String Yes 2019-11-18Z The beginning of the time range to query. Specify the time in the yyyy-MM-ddZ format.
EndTime String Yes 2019-12-18Z 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-ddZ format.
AccessKeyId String No LTAIfCxxxxxxxxxx The AccessKey ID provided to you by Alibaba Cloud.
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. Pages start from page 1.

Default value: 1.

Response parameters

Parameter Type Example Description
RequestId String A95EC729-3644-4C05-BA29-55CBF1A4504C The ID of the request.
DBClusterId String pc-bp1w2u4xxxxxxxxxx The ID of the cluster.
StartTime String 2019-11-18Z The beginning of the time range during which the data was queried.
EndTime String 2019-12-18Z The end of the time range during which the data was queried.
Engine String polardb_mysql The database engine.
TotalRecordCount Integer 1 The total number of slow SQL statements that were queried.
PageNumber Integer 1 The page number of the returned page.
PageRecordCount Integer 1 The number of slow SQL statements on the current page.
Items Array The log information about slow queries.
DBNodeId String pi-bp13oz7xxxxxxxxxx The ID of the node.
ParseMaxRowCount Long 0 The maximum number of rows parsed by the SQL query.
TotalLockTimes Long 0 The total lock duration of the SQL statement. Unit: seconds.
DBName String testdb The name of the database.
MaxExecutionTime Long 10597 The maximum amount of time it took to execute the SQL statement. Unit: seconds.
SQLHASH String 50e94bcxxxxxxxxxxxxxxxx The unique ID of the SQL statement in the slow query log statistics. It can be used to query the slow query log details of the SQL statement.
SQLText String binlog dump The SQL statement recorded in the log.
CreateTime String 2019-11-27Z The date when the data was generated.
TotalExecutionTimes Long 10597 The total amount of time it took to execute the SQL statement. Unit: seconds.
ReturnTotalRowCounts Long 0 The total number of rows returned by the SQL query.
TotalExecutionCounts Long 1 The total number of times that the SQL statement was executed.
MaxLockTime Long 0 The maximum lock duration of the SQL statement. Unit: seconds.
ReturnMaxRowCount Long 0 The maximum number of rows returned by the SQL query.
ParseTotalRowCounts Long 0 The total number of rows parsed by the SQL query.

Examples

Sample requests

http(s)://polardb.aliyuncs.com/? Action=DescribeSlowLogs
&DBClusterId=pc-bp1w2u4xxxxxxxxxx
&RegionId=cn-hangzhou
&StartTime=2019-11-18Z
&EndTime=2019-12-18Z
&<Common request parameters>

Sample success responses

JSON format

{
    "Items": {
        "SQLSlowLog": [
            {
                "ParseMaxRowCount": 0,
                "TotalExecutionTimes": 10597,
                "TotalExecutionCounts": 1,
                "SQLText": "binlog dump",
                "MaxLockTime": 0,
                "ReturnTotalRowCounts": 0,
                "TotalLockTimes": 0,
                "MaxExecutionTime": 10597,
                "CreateTime": "2019-11-27Z",
                "ParseTotalRowCounts": 0,
                "DBName": "",
                "SQLHASH": "50e94bcxxxxxxxxxxxxxxxx",
                "ReturnMaxRowCount": 0,
                "DBNodeId": "pi-bp13oz7xxxxxxxxxx"
            }
        ]
    },
    "TotalRecordCount": 1,
    "PageNumber": 1,
    "RequestId": "A95EC729-3644-4C05-BA29-55CBF1A4504C",
    "EndTime": "2019-12-18Z",
    "StartTime": "2019-11-18Z",
    "DBClusterId": "pc-bp1w2u4xxxxxxxxxx",
    "Engine": "polardb_mysql",
    "PageRecordCount": 1
}

XML format

<Items>
    <SQLSlowLog>
        <ParseMaxRowCount>0</ParseMaxRowCount>
        <TotalExecutionTimes>10597</TotalExecutionTimes>
        <TotalExecutionCounts>1</TotalExecutionCounts>
        <SQLText>binlog dump</SQLText>
        <MaxLockTime>0</MaxLockTime>
        <ReturnTotalRowCounts>0</ReturnTotalRowCounts>
        <TotalLockTimes>0</TotalLockTimes>
        <MaxExecutionTime>10597</MaxExecutionTime>
        <CreateTime>2019-11-27Z</CreateTime>
        <ParseTotalRowCounts>0</ParseTotalRowCounts>
        <DBName/>
        <SQLHASH>50e94bcxxxxxxxxxxxxxxxx</SQLHASH>
        <ReturnMaxRowCount>0</ReturnMaxRowCount>
        <DBNodeId>pi-bp13oz7xxxxxxxxxx</DBNodeId>
    </SQLSlowLog>
</Items>
<TotalRecordCount>1</TotalRecordCount>
<PageNumber>1</PageNumber>
<RequestId>A95EC729-3644-4C05-BA29-55CBF1A4504C</RequestId>
<EndTime>2019-12-18Z</EndTime>
<StartTime>2019-11-18Z</StartTime>
<DBClusterId>pc-bp1w2u4xxxxxxxxxx</DBClusterId>
<Engine>polardb_mysql</Engine>
<PageRecordCount>1</PageRecordCount>

Error code

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