You can call the DescribeSlowLogs operation to query the summary of the slow query logs of an instance.
Before you call this operation, make sure that the instance runs one of the following database engine versions:
- All MySQL versions other than MySQL 5.7 on RDS Basic Edition
- SQL Server 2008 R2
- MariaDB 10.3
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| Action | String | Yes | DescribeSlowLogs | The operation that you want to perform. Set the value to DescribeSlowLogs. |
| DBInstanceId | String | Yes | rm-uf6wjk5xxxxxxx | The ID of the instance. |
| StartTime | String | Yes | 2011-05-01Z | The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddZ format. The time must be in UTC. |
| EndTime | String | Yes | 2011-05-30Z | The end of the time range to query. The end time must be later than the start time. The time span between the start time and the end time cannot exceed 31 days. Specify the time in the ISO 8601 standard in the yyyy-MM-ddZ format. The time must be in UTC. |
| DBName | String | No | RDS_MySQL | The name of the database. |
| SortKey | String | No | TotalExecutionCounts | The dimension based on which ApsaraDB RDS sorts the entries to return. Valid values:
Note This parameter is supported only for instances that run SQL Server 2008 R2. |
| PageSize | Integer | No | 30 | The number of entries to return on each page. Valid values: 30 to 100. Default value: 30. |
| PageNumber | Integer | No | 1 | The number of the page to return. Valid values: any non-zero positive integer. Default value: 1. |
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| EndTime | String | 2011-05-30Z | The end date of the time range that was queried. |
| StartTime | String | 2011-05-30Z | The start date of the time range that was queried. |
| RequestId | String | 2553A660-E4EB-4AF4-A402-8AFF70A49143 | The ID of the request. |
| PageRecordCount | Integer | 10 | The number of SQL statements that are returned on the current page. |
| TotalRecordCount | Integer | 5 | The total number of returned entries. |
| DBInstanceId | String | rm-uf6wjk5xxxxxxx | The ID of the instance. |
| PageNumber | Integer | 1 | The page number of the returned page. |
| Engine | String | MySQL | The database engine that the instance runs. |
| Items | Array of SQLSlowLog | An array that consists of the information about each slow query. | |
| SQLSlowLog | |||
| MaxLastRowsAffectedCounts | Long | 0 | The largest number of rows that were affected by the last SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| ReturnMaxRowCount | Long | 1 | The largest number of rows that were returned by a specific SQL statement in the query. |
| SQLText | String | select id,name from tb_table | The SQL statement that was executed in the query. |
| SQLServerMaxCpuTime | Long | 0 | The largest amount of CPU time that was used by a specific SQL statement in the query. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| CreateTime | String | 2011-05-30Z | The date when the data was generated. |
| AvgLastRowsAffectedCounts | Long | 0 | The average number of rows that were affected by the last SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| MinLastRowsAffectedCounts | Long | 0 | The smallest number of rows that were affected by the last SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| ParseTotalRowCounts | Long | 1 | The total number of rows that were parsed by all SQL statements in the query. |
| TotalLockTimes | Long | 0 | The total lock duration that was caused by all SQL statements in the query. Unit: seconds. |
| MySQLTotalExecutionCounts | Long | 1 | The total number of SQL statements that were executed in the query. This parameter is returned only for instances that run MySQL. |
| SQLServerMinCpuTime | Long | 0 | The smallest amount of CPU time that was used by a specific SQL statement. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| SQLHASH | String | U2FsdGVkxxxx | The unique ID of the SQL statement. The ID is used to obtain the slow query logs of the SQL statement. |
| MinIOWriteCounts | Long | 0 | The smallest number of I/O writes that were performed by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| ParseMaxRowCount | Long | 1 | The largest number of rows that were parsed by a specific SQL statement in the query. |
| MaxLogicalReadCounts | Long | 0 | The largest number of logical reads that were performed by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| MySQLTotalExecutionTimes | Long | 1 | The total execution duration of all SQL statements in the query. This parameter is returned only for instances that run MySQL. Unit: seconds. |
| SQLServerTotalExecutionCounts | Long | 1 | The total number of SQL statements that were executed in the query. This parameter is returned only for instances that run SQL Server. |
| ReturnTotalRowCounts | Long | 1 | The total number of rows that were returned by all SQL statements in the query. |
| MaxLockTime | Long | 0 | The longest lock duration that was caused by a specific SQL statement in the query. Unit: seconds. |
| DBName | String | RDS_MySQL | The name of the database. |
| MinRowsAffectedCounts | Long | 0 | The smallest number of rows that were affected by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| TotalLogicalReadCounts | Long | 1 | The total number of logical reads that were performed by all SQL statements in the query. |
| TotalPhysicalReadCounts | Long | 1 | The total number of physical reads that were performed by all SQL statements in the query . |
| ReportTime | String | 2011-05-30Z | The date on which the data report was generated. |
| MaxPhysicalReadCounts | Long | 0 | The largest number of physical reads that were performed by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| SQLServerTotalCpuTime | Long | 0 | The total amount of CPU time that was used by all SQL statements in the query. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| TotalIOWriteCounts | Long | 0 | The total number of I/O writes that were performed by all SQL statements in the query. Note This parameter is returned only for instances that run SQL Server. |
| MaxRowsAffectedCounts | Long | 0 | The largest number of rows that were affected by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| AvgIOWriteCounts | Long | 0 | The average number of I/O writes per SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| MinPhysicalReadCounts | Long | 0 | The smallest number of physical reads that were performed by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| SlowLogId | Long | 26584213 | The ID of the slow query log summary. |
| MaxExecutionTime | Long | 60 | The longest execution duration of a specific SQL statement in the query. Unit: seconds. |
| AvgExecutionTime | Long | 1 | The average execution duration per SQL statement in the query. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| SQLServerAvgExecutionTime | Long | 0 | The average execution duration per SQL statement in the query. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| MaxIOWriteCounts | Long | 0 | The largest number of I/O writes that were performed by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| SQLServerAvgCpuTime | Long | 0 | The average amount of CPU time per SQL statement in the query. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| TotalLastRowsAffectedCounts | Long | 0 | The total number of rows that were affected by the last SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| AvgLogicalReadCounts | Long | 0 | The average number of logical reads per SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| SQLServerMinExecutionTime | Long | 0 | The smallest execution duration of a specific SQL statement in the query. Unit: seconds. Note This parameter is returned only for instances that run SQL Server. |
| SQLIdStr | String | 521584 | The ID of the SQL statement in the statistical template of slow query logs. This parameter is replaced by the SQLHASH parameter. |
| SQLServerTotalExecutionTimes | Long | 1000 | The total execution duration of all SQL statements in the query. This parameter is returned only for instances that run SQL Server. Unit: milliseconds. |
| AvgRowsAffectedCounts | Long | 0 | The average number of rows that were affected per SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| TotalRowsAffectedCounts | Long | 0 | The total number of rows that were affected by all SQL statements in the query. |
| AvgPhysicalReadCounts | Long | 0 | The average number of physical reads per SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
| MinLogicalReadCounts | Long | 0 | The smallest number of logical reads that were performed by a specific SQL statement in the query. Note This parameter is returned only for instances that run SQL Server. |
Examples
Sample requests
http(s)://rds.aliyuncs.com/?Action=DescribeSlowLogs
&DBInstanceId=rm-uf6wjk5xxxxxxx
&StartTime=2011-05-01Z
&EndTime=2011-05-30Z
&<Common request parameters>Sample success response
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<DescribeSlowLogsResponse>
<EndTime>2011-05-30Z</EndTime>
<StartTime>2011-05-30Z</StartTime>
<RequestId>2553A660-E4EB-4AF4-A402-8AFF70A49143</RequestId>
<PageRecordCount>10</PageRecordCount>
<TotalRecordCount>5</TotalRecordCount>
<DBInstanceId>rm-uf6wjk5xxxxxxx</DBInstanceId>
<PageNumber>1</PageNumber>
<Engine>MySQL</Engine>
<Items>
<MaxLastRowsAffectedCounts>0</MaxLastRowsAffectedCounts>
<ReturnMaxRowCount>1</ReturnMaxRowCount>
<SQLText>select id,name from tb_table</SQLText>
<SQLServerMaxCpuTime>0</SQLServerMaxCpuTime>
<CreateTime>2011-05-30Z</CreateTime>
<AvgLastRowsAffectedCounts>0</AvgLastRowsAffectedCounts>
<MinLastRowsAffectedCounts>0</MinLastRowsAffectedCounts>
<ParseTotalRowCounts>1</ParseTotalRowCounts>
<TotalLockTimes>0</TotalLockTimes>
<MySQLTotalExecutionCounts>1</MySQLTotalExecutionCounts>
<SQLServerMinCpuTime>0</SQLServerMinCpuTime>
<SQLHASH>U2FsdGVkxxxx</SQLHASH>
<MinIOWriteCounts>0</MinIOWriteCounts>
<ParseMaxRowCount>1</ParseMaxRowCount>
<MaxLogicalReadCounts>0</MaxLogicalReadCounts>
<MySQLTotalExecutionTimes>1</MySQLTotalExecutionTimes>
<SQLServerTotalExecutionCounts>1</SQLServerTotalExecutionCounts>
<ReturnTotalRowCounts>1</ReturnTotalRowCounts>
<MaxLockTime>0</MaxLockTime>
<DBName>RDS_MySQL</DBName>
<MinRowsAffectedCounts>0</MinRowsAffectedCounts>
<TotalLogicalReadCounts>1</TotalLogicalReadCounts>
<TotalPhysicalReadCounts>1</TotalPhysicalReadCounts>
<ReportTime>2011-05-30Z</ReportTime>
<MaxPhysicalReadCounts>0</MaxPhysicalReadCounts>
<SQLServerTotalCpuTime>0</SQLServerTotalCpuTime>
<TotalIOWriteCounts>0</TotalIOWriteCounts>
<MaxRowsAffectedCounts>0</MaxRowsAffectedCounts>
<AvgIOWriteCounts>0</AvgIOWriteCounts>
<MinPhysicalReadCounts>0</MinPhysicalReadCounts>
<SlowLogId>26584213</SlowLogId>
<MaxExecutionTime>60</MaxExecutionTime>
<AvgExecutionTime>1</AvgExecutionTime>
<SQLServerAvgExecutionTime>0</SQLServerAvgExecutionTime>
<MaxIOWriteCounts>0</MaxIOWriteCounts>
<SQLServerAvgCpuTime>0</SQLServerAvgCpuTime>
<TotalLastRowsAffectedCounts>0</TotalLastRowsAffectedCounts>
<AvgLogicalReadCounts>0</AvgLogicalReadCounts>
<SQLServerMinExecutionTime>0</SQLServerMinExecutionTime>
<SQLIdStr>521584</SQLIdStr>
<SQLServerTotalExecutionTimes>1000</SQLServerTotalExecutionTimes>
<AvgRowsAffectedCounts>0</AvgRowsAffectedCounts>
<TotalRowsAffectedCounts>0</TotalRowsAffectedCounts>
<AvgPhysicalReadCounts>0</AvgPhysicalReadCounts>
<MinLogicalReadCounts>0</MinLogicalReadCounts>
</Items>
</DescribeSlowLogsResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"EndTime" : "2011-05-30Z",
"StartTime" : "2011-05-30Z",
"RequestId" : "2553A660-E4EB-4AF4-A402-8AFF70A49143",
"PageRecordCount" : 10,
"TotalRecordCount" : 5,
"DBInstanceId" : "rm-uf6wjk5xxxxxxx",
"PageNumber" : 1,
"Engine" : "MySQL",
"Items" : [ {
"MaxLastRowsAffectedCounts" : 0,
"ReturnMaxRowCount" : 1,
"SQLText" : "select id,name from tb_table",
"SQLServerMaxCpuTime" : 0,
"CreateTime" : "2011-05-30Z",
"AvgLastRowsAffectedCounts" : 0,
"MinLastRowsAffectedCounts" : 0,
"ParseTotalRowCounts" : 1,
"TotalLockTimes" : 0,
"MySQLTotalExecutionCounts" : 1,
"SQLServerMinCpuTime" : 0,
"SQLHASH" : "U2FsdGVkxxxx",
"MinIOWriteCounts" : 0,
"ParseMaxRowCount" : 1,
"MaxLogicalReadCounts" : 0,
"MySQLTotalExecutionTimes" : 1,
"SQLServerTotalExecutionCounts" : 1,
"ReturnTotalRowCounts" : 1,
"MaxLockTime" : 0,
"DBName" : "RDS_MySQL",
"MinRowsAffectedCounts" : 0,
"TotalLogicalReadCounts" : 1,
"TotalPhysicalReadCounts" : 1,
"ReportTime" : "2011-05-30Z",
"MaxPhysicalReadCounts" : 0,
"SQLServerTotalCpuTime" : 0,
"TotalIOWriteCounts" : 0,
"MaxRowsAffectedCounts" : 0,
"AvgIOWriteCounts" : 0,
"MinPhysicalReadCounts" : 0,
"SlowLogId" : 26584213,
"MaxExecutionTime" : 60,
"AvgExecutionTime" : 1,
"SQLServerAvgExecutionTime" : 0,
"MaxIOWriteCounts" : 0,
"SQLServerAvgCpuTime" : 0,
"TotalLastRowsAffectedCounts" : 0,
"AvgLogicalReadCounts" : 0,
"SQLServerMinExecutionTime" : 0,
"SQLIdStr" : "521584",
"SQLServerTotalExecutionTimes" : 1000,
"AvgRowsAffectedCounts" : 0,
"TotalRowsAffectedCounts" : 0,
"AvgPhysicalReadCounts" : 0,
"MinLogicalReadCounts" : 0
} ]
}Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | InvalidSearchTimeRange | search time range cannot be longer than a month. | The error message returned because the time span between the start time and the end time exceeds 31 days. Enter a valid value for the StartTime or EndTime parameter. |
| 400 | IO.Exception | IO exception, retry later. | The error message returned because I/O errors occurred. |
For a list of error codes, see Service error codes.