Retrieve slow query statistics for a time range.
Try it now
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| DBInstanceId |
string |
Yes |
The instance ID. |
selectdb-cn-7213cjv**** |
| RegionId |
string |
Yes |
The region ID. |
cn-shenzhen |
| StartTime |
string |
No |
The start time. Defaults to 24 hours before the current time. |
2026-04-07 16:00:00 |
| EndTime |
string |
No |
The end time. Must be later than the start time. Defaults to the current time. |
2026-04-08 16:00:00 |
| ThresholdMs |
integer |
No |
The slow query threshold, in milliseconds. The default value is 5000. |
5000 |
| TopN |
integer |
No |
The number of top slow queries to return. The default value is 10. |
10 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The data returned. |
||
| RequestId |
string |
The request ID. |
FCEEA97F-XXXX-XXXX-932F-B4BAEA170896 |
| Summary |
object |
The summary of slow query statistics. |
{ "totalAllQueries": "4531", "maxScanBytes": "279794422882", "totalQueries": "45", "minScanRows": "0", "totalScanRows": "214219674180", "errorQueryCount": "0", "avgLatency": "9862", "minLatency": "5051", "maxLatency": "24746", "totalScanBytes": "4657224498428", "avgScanBytes": "103493877742", "distinctUsers": "1", "minScanBytes": "0", "slowQueryRatio": "0.009931582432134187", "maxScanRows": "23040660808", "avgCpuTimeMs": "649451", "avgScanRows": "4760437204", "maxCpuTimeMs": "1368932", "totalCpuTimeMs": "29225330" } |
| Percentiles |
object |
The percentile statistics for query latency. |
{ "p99": "24746.0", "p50": "8295.0", "p95": "23872.0", "p90": "15794.0", "p75": "11972.25" } |
| ByUser |
any |
An array of slow query statistics, grouped by user. |
[ { "maxScanBytes": 279794422882, "minScanRows": 0, "totalScanRows": 214219674180, "avgLatency": 9862.755555555555, "minLatency": 5051, "maxLatency": 24746, "totalScanBytes": 4657224498428, "queryCount": 45, "avgScanBytes": 103493877742.84445, "minScanBytes": 0, "totalLatency": 443824, "maxScanRows": 23040660808, "avgCpuTimeMs": 649451.7777777778, "avgScanRows": 4760437204, "maxCpuTimeMs": 1368932, "distinctSqlDigests": 1, "user": "admin", "totalCpuTimeMs": 29225330, "minCpuTimeMs": 2434 } ] |
| ByTimeBucket |
any |
An array of slow query statistics, grouped by time bucket. |
[ { "maxScanBytes": 261400873691, "minScanRows": 5915582721, "totalScanRows": 23662330884, "avgLatency": 6988.5, "minLatency": 6657, "maxLatency": 7401, "totalScanBytes": 1045601376995, "queryCount": 4, "avgScanBytes": 261400344248.75, "minScanBytes": 261400167768, "maxScanRows": 5915582721, "avgCpuTimeMs": 603488.25, "avgScanRows": 5915582721, "maxCpuTimeMs": 637311, "timeBucket": "2026-04-15 22:00:00", "totalCpuTimeMs": 2413953, "minCpuTimeMs": 567462 } ] |
| TopQueries |
any |
An array of detailed audit records for the top N slow queries. |
[ { "peakMemoryBytes": 71731165356, "planTimesMs": "{\"plan\":15, \"garbage_collect\":0, \"lock_tables\":0, \"analyze\":2, \"rewrite\":4, \"fold_const_by_be\":0, \"collect_partitions\":0, \"optimize\":3, \"translate\":2, \"init_scan_node\":-1, \"finalize_scan_node\":-1, \"create_scan_range\":-1, \"distribute\":4}", "catalog": "internal", "sqlMode": "ONLY_FULL_GROUP_BY", "errorCode": 0, "spillReadBytesFromLocalStorage": -1, "computeGroup": "test", "queryId": "921f10bc054d4dbb-903784520a2ab26f", "parseTimeMs": 0, "stmtId": 5822, "hitSqlCache": false, "chosenMViews": "[]", "scanBytesFromLocalStorage": 861079963, "frontendIp": "172.16.17.192", "handledInFe": false, "returnRows": 100, "state": "EOF", "scanRows": 550584606, "cpuTimeMs": 1368932, "scheduleTimesMs": "{\"schedule_time_ms\":14, \"fragment_assign_time_ms\":0, \"fragment_serialize_time_ms\":2, \"fragment_rpc_phase_1_time_ms\":11, \"fragment_rpc_phase_2_time_ms\":1, \"fragment_compressed_size_byte\":142152, \"fragment_rpc_count\":6}", "shuffleSendBytes": 27745167331, "stmtType": "SELECT", "sqlHash": "ecf08bbca3e4b33b1630e03a9dc671b4", "errorMessage": "", "isQuery": true, "isNereids": true, "changedVariables": "{\"enable_profile\":\"true\", \"enable_auto_analyze\":\"false\", \"runtime_filter_wait_time_ms\":\"10000\", \"sql_converter_service_url\":\"http://127.0.0.1:5001/api/v1/convert\"}", "scanBytesFromRemoteStorage": 0, "scanBytes": 11358721363, "isInternal": false, "workloadGroup": "normal", "queriedTablesAndViews": "[\"internal.tpcds_1000g.item\", \"internal.tpcds_1000g.store_sales\", \"internal.tpcds_1000g.date_dim\", \"internal.tpcds_1000g.store\"]", "sqlDigest": "d41d8cd98f00b204e9800998ecf8427e", "clientIp": "123.56.117.27:33664", "queryTime": 24746, "shuffleSendRows": 454538612, "time": "1776267563848", "getMetaTimesMs": "{\"get_partition_version_time_ms\":3381937, \"get_partition_version_count_has_data\":0, \"get_partition_version_count\":1, \"get_table_version_time_ms\":0, \"get_table_version_count\":0}", "spillWriteBytesFromLocalStorage": -1, "user": "admin", "db": "tpcds_1000g", "stmt": "xxx" } ] |
| TopSqlDigests |
any |
An array of statistics for the top N slow queries, grouped by SQL digest. Available for kernel version 5.0 and later. |
[ { "maxScanBytes": 279794422882, "minScanRows": 0, "totalScanRows": 214219674180, "avgLatency": 9862.755555555555, "minLatency": 5051, "maxLatency": 24746, "totalScanBytes": 4657224498428, "queryCount": 45, "avgScanBytes": 103493877742.84445, "minScanBytes": 0, "totalLatency": 443824, "sqlDigest": "d41d8cd98f00b204e9800998ecf8427e", "maxScanRows": 23040660808, "avgCpuTimeMs": 649451.7777777778, "avgScanRows": 4760437204, "maxCpuTimeMs": 1368932, "sampleStmt": "xxx", "user": "admin", "db": "tpcds_1000g", "totalCpuTimeMs": 29225330, "minCpuTimeMs": 2434 } ] |
| ByDatabase |
any |
An array of slow query statistics, grouped by database. |
[ { "maxScanBytes": 271603242215, "minScanRows": 550584606, "totalScanRows": 96977924056, "avgLatency": 10804, "minLatency": 5138, "maxLatency": 24746, "totalScanBytes": 1441239240695, "queryCount": 29, "avgScanBytes": 49697904851, "minScanBytes": 8691897406, "totalLatency": 313322, "maxScanRows": 23040660808, "avgCpuTimeMs": 732085, "avgScanRows": 3344066346, "maxCpuTimeMs": 1368932, "db": "tpcds_1000g", "totalCpuTimeMs": 21230477, "minCpuTimeMs": 292711 } ] |
Examples
Success response
JSON format
{
"RequestId": "FCEEA97F-XXXX-XXXX-932F-B4BAEA170896",
"Summary": {
"totalAllQueries": "4531",
"maxScanBytes": "279794422882",
"totalQueries": "45",
"minScanRows": "0",
"totalScanRows": "214219674180",
"errorQueryCount": "0",
"avgLatency": "9862",
"minLatency": "5051",
"maxLatency": "24746",
"totalScanBytes": "4657224498428",
"avgScanBytes": "103493877742",
"distinctUsers": "1",
"minScanBytes": "0",
"slowQueryRatio": "0.009931582432134187",
"maxScanRows": "23040660808",
"avgCpuTimeMs": "649451",
"avgScanRows": "4760437204",
"maxCpuTimeMs": "1368932",
"totalCpuTimeMs": "29225330"
},
"Percentiles": {
"p99": "24746.0",
"p50": "8295.0",
"p95": "23872.0",
"p90": "15794.0",
"p75": "11972.25"
},
"ByUser": "[\n {\n \"maxScanBytes\": 279794422882,\n \"minScanRows\": 0,\n \"totalScanRows\": 214219674180,\n \"avgLatency\": 9862.755555555555,\n \"minLatency\": 5051,\n \"maxLatency\": 24746,\n \"totalScanBytes\": 4657224498428,\n \"queryCount\": 45,\n \"avgScanBytes\": 103493877742.84445,\n \"minScanBytes\": 0,\n \"totalLatency\": 443824,\n \"maxScanRows\": 23040660808,\n \"avgCpuTimeMs\": 649451.7777777778,\n \"avgScanRows\": 4760437204,\n \"maxCpuTimeMs\": 1368932,\n \"distinctSqlDigests\": 1,\n \"user\": \"admin\",\n \"totalCpuTimeMs\": 29225330,\n \"minCpuTimeMs\": 2434\n }\n ]",
"ByTimeBucket": "[\n {\n \"maxScanBytes\": 261400873691,\n \"minScanRows\": 5915582721,\n \"totalScanRows\": 23662330884,\n \"avgLatency\": 6988.5,\n \"minLatency\": 6657,\n \"maxLatency\": 7401,\n \"totalScanBytes\": 1045601376995,\n \"queryCount\": 4,\n \"avgScanBytes\": 261400344248.75,\n \"minScanBytes\": 261400167768,\n \"maxScanRows\": 5915582721,\n \"avgCpuTimeMs\": 603488.25,\n \"avgScanRows\": 5915582721,\n \"maxCpuTimeMs\": 637311,\n \"timeBucket\": \"2026-04-15 22:00:00\",\n \"totalCpuTimeMs\": 2413953,\n \"minCpuTimeMs\": 567462\n }\n]",
"TopQueries": "[\n {\n \"peakMemoryBytes\": 71731165356,\n \"planTimesMs\": \"{\\\"plan\\\":15, \\\"garbage_collect\\\":0, \\\"lock_tables\\\":0, \\\"analyze\\\":2, \\\"rewrite\\\":4, \\\"fold_const_by_be\\\":0, \\\"collect_partitions\\\":0, \\\"optimize\\\":3, \\\"translate\\\":2, \\\"init_scan_node\\\":-1, \\\"finalize_scan_node\\\":-1, \\\"create_scan_range\\\":-1, \\\"distribute\\\":4}\",\n \"catalog\": \"internal\",\n \"sqlMode\": \"ONLY_FULL_GROUP_BY\",\n \"errorCode\": 0,\n \"spillReadBytesFromLocalStorage\": -1,\n \"computeGroup\": \"test\",\n \"queryId\": \"921f10bc054d4dbb-903784520a2ab26f\",\n \"parseTimeMs\": 0,\n \"stmtId\": 5822,\n \"hitSqlCache\": false,\n \"chosenMViews\": \"[]\",\n \"scanBytesFromLocalStorage\": 861079963,\n \"frontendIp\": \"172.16.17.192\",\n \"handledInFe\": false,\n \"returnRows\": 100,\n \"state\": \"EOF\",\n \"scanRows\": 550584606,\n \"cpuTimeMs\": 1368932,\n \"scheduleTimesMs\": \"{\\\"schedule_time_ms\\\":14, \\\"fragment_assign_time_ms\\\":0, \\\"fragment_serialize_time_ms\\\":2, \\\"fragment_rpc_phase_1_time_ms\\\":11, \\\"fragment_rpc_phase_2_time_ms\\\":1, \\\"fragment_compressed_size_byte\\\":142152, \\\"fragment_rpc_count\\\":6}\",\n \"shuffleSendBytes\": 27745167331,\n \"stmtType\": \"SELECT\",\n \"sqlHash\": \"ecf08bbca3e4b33b1630e03a9dc671b4\",\n \"errorMessage\": \"\",\n \"isQuery\": true,\n \"isNereids\": true,\n \"changedVariables\": \"{\\\"enable_profile\\\":\\\"true\\\", \\\"enable_auto_analyze\\\":\\\"false\\\", \\\"runtime_filter_wait_time_ms\\\":\\\"10000\\\", \\\"sql_converter_service_url\\\":\\\"http://127.0.0.1:5001/api/v1/convert\\\"}\",\n \"scanBytesFromRemoteStorage\": 0,\n \"scanBytes\": 11358721363,\n \"isInternal\": false,\n \"workloadGroup\": \"normal\",\n \"queriedTablesAndViews\": \"[\\\"internal.tpcds_1000g.item\\\", \\\"internal.tpcds_1000g.store_sales\\\", \\\"internal.tpcds_1000g.date_dim\\\", \\\"internal.tpcds_1000g.store\\\"]\",\n \"sqlDigest\": \"d41d8cd98f00b204e9800998ecf8427e\",\n \"clientIp\": \"123.56.117.27:33664\",\n \"queryTime\": 24746,\n \"shuffleSendRows\": 454538612,\n \"time\": \"1776267563848\",\n \"getMetaTimesMs\": \"{\\\"get_partition_version_time_ms\\\":3381937, \\\"get_partition_version_count_has_data\\\":0, \\\"get_partition_version_count\\\":1, \\\"get_table_version_time_ms\\\":0, \\\"get_table_version_count\\\":0}\",\n \"spillWriteBytesFromLocalStorage\": -1,\n \"user\": \"admin\",\n \"db\": \"tpcds_1000g\",\n \"stmt\": \"xxx\"\n }\n]",
"TopSqlDigests": "[\n {\n \"maxScanBytes\": 279794422882,\n \"minScanRows\": 0,\n \"totalScanRows\": 214219674180,\n \"avgLatency\": 9862.755555555555,\n \"minLatency\": 5051,\n \"maxLatency\": 24746,\n \"totalScanBytes\": 4657224498428,\n \"queryCount\": 45,\n \"avgScanBytes\": 103493877742.84445,\n \"minScanBytes\": 0,\n \"totalLatency\": 443824,\n \"sqlDigest\": \"d41d8cd98f00b204e9800998ecf8427e\",\n \"maxScanRows\": 23040660808,\n \"avgCpuTimeMs\": 649451.7777777778,\n \"avgScanRows\": 4760437204,\n \"maxCpuTimeMs\": 1368932,\n \"sampleStmt\": \"xxx\",\n \"user\": \"admin\",\n \"db\": \"tpcds_1000g\",\n \"totalCpuTimeMs\": 29225330,\n \"minCpuTimeMs\": 2434\n }\n ]",
"ByDatabase": "[\n {\n \"maxScanBytes\": 271603242215,\n \"minScanRows\": 550584606,\n \"totalScanRows\": 96977924056,\n \"avgLatency\": 10804,\n \"minLatency\": 5138,\n \"maxLatency\": 24746,\n \"totalScanBytes\": 1441239240695,\n \"queryCount\": 29,\n \"avgScanBytes\": 49697904851,\n \"minScanBytes\": 8691897406,\n \"totalLatency\": 313322,\n \"maxScanRows\": 23040660808,\n \"avgCpuTimeMs\": 732085,\n \"avgScanRows\": 3344066346,\n \"maxCpuTimeMs\": 1368932,\n \"db\": \"tpcds_1000g\",\n \"totalCpuTimeMs\": 21230477,\n \"minCpuTimeMs\": 292711\n }\n]"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | DocumentConvertFailed.ExceedFileSizeLimit | The conversion has been failed, exceed file size limit. | english description1 |
| 400 | Forbidden | User not authorized to operate on the specified resource, or this API does not support RAM. | english description1 |
| 400 | InvalidDBName | The specified database name is not allowed. | english description1 |
| 400 | CreateOrderFailed | Failed to create order. | Failed to create order. |
| 400 | InvalidDBInstanceId.Malformed | The specified parameter "DBInstanceId" is not valid. | The parameter "DBInstanceId" is illegal. |
| 400 | InvalidParameters.Format | Specified parameters is not valid. | Incoming parameter is not a valid parameter |
| 400 | InvalidParameter | Specified parameter is not valid. | Specified parameter is not valid. |
| 403 | DBClusterNotSupported | The requested operation can not be performed while the cluster is not sale. | The requested operation cannot be performed while the cluster is not running. |
| 403 | IncorrectDBInstanceState | Current DB instance state does not support this operation. | english description1 |
| 403 | InstanceEngineType.NotSupport | The instance engine and type does not support operations. | english description1 |
| 403 | InvalidDBInstanceState.NotSupport | The specified instance state does't support this operation. | The instance is in a state that does not support the current operation. |
| 403 | MoneyLessThan100 | The Account Monet less Than 100. | english description1 |
| 403 | OperationDenied.DBNameAndAccountPrivilegeCount | The operation is not permitted due to count of database or account privilege. | english description1 |
| 403 | InsufficientResourceCapacity | The resource is out of usage. | Not enough resources, please try again later. |
| 403 | IncorrectEngineVersion | Current engine version does not support operations. | Current engine version does not support operations. |
| 403 | IncorrectMinorVersion | Current engine minor version does not support operations. | Current engine minor version does not support operations. |
| 404 | DBInstanceLocked | The current instance lock mode does not support this operation. | english description1 |
| 404 | IncorrectVswitchId | The specified parameter VSwitchId is not valid. | english description1 |
| 404 | InvalidApi.NotFound | Specified api is not found, please check your url and method. | |
| 404 | InvalidDBInstance.NotFound | The specified instance is not found. | english description1 |
| 404 | InvalidDBInstanceClass.NotFound | The specified instance classic does not exist. | english description1 |
| 404 | InvalidRegionId.NotFound | The provided RegionId does not exist in our records. | english description1 |
| 404 | QueryPrice.Failed | The inquiry failed. Contact Alibaba Cloud customer service representatives. | english description1 |
| 404 | InvalidDBInstanceId.NotFound | The DBInstanceId provided does not exist in our records. | Instance does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.