You can call this operation to query logs of slow queries for an Apsara PolarDB cluster.

If you want to call this operation, the database engine of the specified cluster must be 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 DescribeSlowLogRecords

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

DBClusterId String Yes pc-bpxxxxxxxxxxxxxxx

The ID of the Apsara PolarDB cluster that you want to manage.

RegionId String Yes cn-hangzhou

The region ID of the Apsara PolarDB cluster that you want to manage.

Note You can call the DescribeRegions operation to query the most recent region list.
StartTime String Yes 2019-11-18T16: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.

EndTime String Yes 2019-12-18T16:00Z

The end of the time range to query. The end time must be later than the start time. The specified time range must be less than 31 days. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

DBName String No testdb

The name of the database that you want to manage.

PageSize Integer No 30

The number of entries to return on each page. Valid values: 30, 50, and 100.

Default value: 30

PageNumber Integer No 1

The number of the page to return. Pages start from page 1.

Default value: 1

SQLHASH String No U2FsdGVkxxxx

The unique ID of the SQL statement included in the slow query log statistics. You can use the unique ID to query logs of slow queries on the SQL statement.

Note You can call the DescribeSlowLogs operation to retrieve the value of this parameter.
AccessKeyId String No LTAIfCxxxxxxxxxx

The AccessKey ID provided to you by Alibaba Cloud.

Response parameters

Parameter Type Example Description
RequestId String BF2F38D4-5D03-442C-AFBD-8D266E2D08AF

The ID of the request.

DBClusterId String pc-bpxxxxxxxxxxxxxxx

The ID of the Apsara PolarDB cluster.

Engine String MySQL

The engine of the database.

TotalRecordCount Integer 1

The total number of slow SQL queries.

PageNumber Integer 1

The page number of the returned page.

PageRecordCount Integer 1

The number of slow SQL queries on the current page.

Items Array

The details of slow query logs.

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

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

DBName String testdb

The name of the database.

SQLText String Binlog Dump

The SQL statement recorded in the log.

QueryTimes Long 10597

The amount of time taken for the system to execute the SQL statement, in seconds.

LockTimes Long 0

The duration for which the SQL statement is locked, in seconds.

ParseRowCounts Long 0

The number of parsed rows.

ReturnRowCounts Long 0

The number of returned rows.

ExecutionStartTime String 2019-11-27T05:18:06Z

The time when the SQL statement started to be executed. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

DBNodeId String pi-bp13oz7xxxxxxxxxx

The ID of the node.

Examples

Sample requests

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

Sample success responses

JSON format

{
	"Items": {
		"SQLSlowRecord": [
            {
				"ReturnRowCounts": 0,
				"HostAddress": "testdb[testdb] @  [100. **. **.242]",
				"SQLText": "Binlog Dump",
				"LockTimes": 0,
				"ExecutionStartTime": "2019-11-27T05:18:06Z",
				"ParseRowCounts": 0,
				"QueryTimes": 10597,
				"DBName": "testdb",
				"DBNodeId": "pi-bp13oz7xxxxxxxxxx"
			}
		]
	},
	"TotalRecordCount": 1,
	"PageNumber": 1,
	"RequestId": "BF2F38D4-5D03-442C-AFBD-8D266E2D08AF",
	"DBClusterId": "pc-bp1w2u4**********",
	"Engine": "polardb_mysql",
	"PageRecordCount": 1
}

XML format

<Items>
    <SQLSlowRecord>
        <ReturnRowCounts>0</ReturnRowCounts>
        <HostAddress>testdb[testdb] @  [100. **. **.242]</HostAddress>
        <SQLText>Binlog Dump</SQLText>
        <LockTimes>0</LockTimes>
        <ExecutionStartTime>2019-11-27T05:18:06Z</ExecutionStartTime>
        <ParseRowCounts>0</ParseRowCounts>
        <QueryTimes>10597</QueryTimes>
        <DBName>testdb</DBName>
        <DBNodeId>pi-bp13oz7xxxxxxxxxx</DBNodeId>
    </SQLSlowRecord>
</Items>
<TotalRecordCount>1</TotalRecordCount>
<PageNumber>1</PageNumber>
<RequestId>BF2F38D4-5D03-442C-AFBD-8D266E2D08AF</RequestId>
<DBClusterId>pc-bp1w2u4**********</DBClusterId>
<Engine>polardb_mysql</Engine>
<PageRecordCount>1</PageRecordCount>

Error codes

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