Queries the details of slow query logs for a PolarDB cluster.
Operation description
This operation is supported only for PolarDB for MySQL clusters.
For PolarDB for PostgreSQL and PolarDB for PostgreSQL (Oracle Compatible) clusters, use the DAS API to query slow log records.
Starting September 1, 2024, the value of the
SQLHashfield will change due to an optimization of the SQL templating algorithm. For more information, see [Notice] Optimization of the templating algorithm for slow SQL queries.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
polardb:DescribeSlowLogRecords |
get |
*dbcluster
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. Note
You can call the DescribeRegions operation to query available regions and their region IDs. |
cn-hangzhou |
| DBClusterId |
string |
Yes |
The cluster ID. Note
You can call the DescribeDBClusters operation to query all clusters in the target region and their cluster IDs. |
pc-************ |
| NodeId |
string |
No |
The node ID. |
pi-********** |
| StartTime |
string |
Yes |
The start of the query time range. Specify the time in UTC in the Note
|
2022-11-15T16:00Z |
| EndTime |
string |
Yes |
The end of the query time range. The end time must be later than the start time. The time range cannot exceed 24 hours. Specify the time in UTC in the Note
The time must be in UTC. If your service is in a different time zone, you must convert the time. For example, to query data from 08:00 to 12:00 in the UTC+8 time zone, you must set the time range from 00:00 UTC to 04:00 UTC. |
2022-11-16T04:00Z |
| DBName |
string |
No |
The database name. |
testdb |
| PageSize |
integer |
No |
The number of records per page. Valid values:
Default value: 30. |
30 |
| PageNumber |
integer |
No |
The page number. The value must be an integer greater than 0. Default value: 1. |
1 |
| SQLHASH |
string |
No |
The SQL hash of a slow query. Obtain this hash from slow query log statistics to retrieve the details of a specific slow query. |
U2FsdGVk**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| DBClusterId |
string |
The cluster ID. |
pc-***************** |
| Engine |
string |
The database engine. |
polardb_mysql |
| Items |
object |
||
| SQLSlowRecord |
array<object> |
The slow query log records. |
|
|
object |
|||
| DBName |
string |
The name of the database. |
testdb |
| DBNodeId |
string |
The node ID. |
pi-***************** |
| ExecutionStartTime |
string |
The execution start time of the SQL statement. The time is in |
2021-04-07T03:47Z |
| HostAddress |
string |
The client address. |
testdb[testdb] @ [100.**.**.242] |
| LockTimes |
integer |
The lock duration, in seconds. |
0 |
| ParseRowCounts |
integer |
The number of parsed rows. |
0 |
| QueryTimeMS |
integer |
The query duration, in milliseconds. |
100 |
| QueryTimes |
integer |
The execution duration, in seconds. |
20 |
| ReturnRowCounts |
integer |
The number of returned rows. |
0 |
| SQLHash |
string |
The unique identifier for the SQL statement. |
U2FsdGVk**** |
| SQLText |
string |
The SQL statement. |
/* Query from *** by user 111 */ SELECT sleep(20) |
| LockTimeMS |
integer |
The lock duration, in milliseconds. |
100 |
| PageNumber |
integer |
The page number. |
1 |
| PageRecordCount |
integer |
The number of records on the current page. |
1 |
| RequestId |
string |
The request ID. |
A7E6A8FD-C50B-46B2-BA85-D8B8D3****** |
| TotalRecordCount |
integer |
The total number of records. |
1 |
Examples
Success response
JSON format
{
"DBClusterId": "pc-*****************",
"Engine": "polardb_mysql",
"Items": {
"SQLSlowRecord": [
{
"DBName": "testdb",
"DBNodeId": "pi-*****************",
"ExecutionStartTime": "2021-04-07T03:47Z",
"HostAddress": "testdb[testdb] @ [100.**.**.242]",
"LockTimes": 0,
"ParseRowCounts": 0,
"QueryTimeMS": 100,
"QueryTimes": 20,
"ReturnRowCounts": 0,
"SQLHash": "U2FsdGVk****",
"SQLText": "/* Query from *** by user 111 */ SELECT sleep(20)",
"LockTimeMS": 100
}
]
},
"PageNumber": 1,
"PageRecordCount": 1,
"RequestId": "A7E6A8FD-C50B-46B2-BA85-D8B8D3******",
"TotalRecordCount": 1
}
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. |
| 404 | InvalidDBClusterId.NotFound | The DBInstanceId provided does not exist in our records. | The specified DBClusterId parameter does not exist in the current record. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.