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 SQLHash field 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 the available regions and their IDs for your account. |
cn-hangzhou |
| DBClusterId |
string |
Yes |
The cluster ID. Note
You can call the DescribeDBClusters operation to query information about all clusters in a region, including cluster IDs. |
pc-************ |
| NodeId |
string |
No |
The node ID. |
pi-********** |
| StartTime |
string |
Yes |
The beginning of the time range to query. Specify the time in the Note
|
2022-11-15T16:00Z |
| EndTime |
string |
Yes |
The end of the time range to query. The end time must be later than the start time. The interval between the start time and the end time cannot exceed 24 hours. Specify the time in the Note
This parameter is specified in UTC. If your service is in a different time zone, convert the time accordingly. For example, if your service is in the UTC+8 time zone and you want to query slow query logs from 08:00 to 12:00 (UTC+8), set the start and end times to 00:00 and 04:00 (UTC). |
2022-11-16T04:00Z |
| DBName |
string |
No |
The name of the database. |
testdb |
| PageSize |
integer |
No |
The number of entries to return on each page. Valid values:
Default value: 30. |
30 |
| PageNumber |
integer |
No |
The page number. The value must be an integer that is greater than 0. The value cannot exceed the maximum value of the Integer data type. Default value: 1. |
1 |
| SQLHASH |
string |
No |
The unique identifier of the SQL statement. You can use this identifier to query the details of the slow SQL 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> |
A list of slow query log details. |
|
|
object |
|||
| DBName |
string |
The name of the database. |
testdb |
| DBNodeId |
string |
The node ID. |
pi-***************** |
| ExecutionStartTime |
string |
The time when the SQL statement started to be executed. The time is in the |
2021-04-07T03:47Z |
| HostAddress |
string |
The address of the client that is connected to the database. |
testdb[testdb] @ [100.**.**.242] |
| LockTimes |
integer |
The lock duration of the SQL statement. Unit: seconds. |
0 |
| ParseRowCounts |
integer |
The number of parsed rows. |
0 |
| QueryTimeMS |
integer |
The query duration. Unit: milliseconds. |
100 |
| QueryTimes |
integer |
The execution duration of the SQL statement. Unit: seconds. |
20 |
| ReturnRowCounts |
integer |
The number of returned rows. |
0 |
| SQLHash |
string |
The unique identifier of the SQL statement. |
U2FsdGVk**** |
| SQLText |
string |
The SQL statement. |
/* Query from *** by user 111 */ SELECT sleep(20) |
| PageNumber |
integer |
The page number. |
1 |
| PageRecordCount |
integer |
The number of entries on the current page. |
1 |
| RequestId |
string |
The request ID. |
A7E6A8FD-C50B-46B2-BA85-D8B8D3****** |
| TotalRecordCount |
integer |
The total number of SQL statements. |
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)"
}
]
},
"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.