Overview
You can call this API to query the sampling data of slow SQL execution details.
API details
Constraints
The caller must have an AccessKey for accessing the multi-cloud API. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
GET /api/v2/open/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/samples
Request parameters
Path
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| instanceId | String | Yes | The ID of the instance. | obxxx |
| tenantId | String | Yes | The ID of the tenant. | txxx |
| sqlId | String | Yes | The ID of the SQL statement. | 5D51DC02208F9A448157FD8A******** |
Query
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| dbName | String | No | The name of the database. | test11 |
| startTime | Long | No | The start time. | 2025-01-01T00:00:00Z |
| endTime | Long | No | The end time. | 2025-01-02T00:00:00Z |
Response parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| data | Object | The data. | {} |
| dataList | Array | The data list. | [] |
| causeType | String | The sampling type. | SLOW_SQL |
| affectedRows | Long | The average number of rows updated during the period. | 0 |
| blockCacheHit | Double | The number of block cache hits. | 0.0 |
| blockIndexCacheHit | Double | The number of block index cache hits. | 0.0 |
| bloomFilterCacheHit | Double | The number of bloom filter cache hits. | 0.0 |
| clientIp | String | The IP address of the client. | xx.xx.xx.xx |
| clientPort | Long | The port number of the client. | 19580 |
| cpuTime | Double | The CPU time in milliseconds. | 1949.68 |
| dbName | String | The name of the database. | test11 |
| decodeTime | Double | The syntax parsing time in milliseconds. | 0.0 |
| diskReads | Double | The number of disk reads. | 0.0 |
| elapsedTime | Double | The response time in milliseconds. | 1956.43 |
| executeTime | Double | The plan execution time in milliseconds. | 1949.66 |
| executorRpc | Boolean | Indicates whether an RPC is initiated. | false |
| expectedWorkerCount | Long | The degree of parallelism. | 0 |
| fullSqlText | String | The complete SQL text. | select * from high_d |
| getPlanTime | Double | The plan generation time in milliseconds. | 0.03 |
| hitPlan | Boolean | Indicates whether the execution plan is hit. | true |
| inner | Boolean | Indicates whether the SQL statement is internal. | false |
| memstoreReadRows | Long | The number of rows read from the MemStore. | 0 |
| netTime | Double | The network transmission time in milliseconds. | 0.0 |
| netWaitTime | Double | The network enqueue time in milliseconds. | 0.0 |
| partitionCount | Long | The average number of partitions accessed during the period. | 1 |
| planId | Long | The ID of the execution plan. | 1049 |
| planType | String | The plan type. | LOCAL |
| queueTime | Double | The queuing time in milliseconds. | 6.75 |
| requestId | Long | The request ID. | 369604 |
| requestTime | String | The request time of the SQL statement. | 2025-12-23T06:47:06.207Z |
| retCode | Long | The result code. | 0 |
| retryCount | Long | The number of retries. | 0 |
| returnRows | Long | The average number of rows returned during the period. | 1 |
| rowCacheHit | Double | The number of row cache hits. | 0.0 |
| rpcCount | Long | The number of RPCs sent. | 0 |
| server | String | The server where the SQL statement is executed. | i-uf******** |
| sqlId | String | The ID of the SQL statement. | 5D51DC02208F9A448157FD8A******** |
| sqlTextShort | String | The short text of the SQL statement. | select * from high_disk_read_2 where id > ? order by id desc limit ? |
| sqlType | String | The type of the SQL statement. | SELECT |
| ssstoreReadRows | Long | The number of rows read from the SsStore. | 525 |
| tableScan | Boolean | Indicates whether a full table scan is performed. | true |
| traceId | String | The trace ID. | YB420A7100C3-00064694CC824665-0-0 |
| transHash | String | The transaction hash. | 0 |
| usedWorkerCount | Long | The number of threads used for SQL execution. | 0 |
| userClientIp | String | The IP address of the user client. | xx.xx.xx.xx |
| userName | String | The username. | test11 |
| waitCount | Long | The number of waits. | 0 |
| waitEvent | String | The longest wait event during the period. | event:, p1text:, p1:0, p2text:, p2:0, p3text:, p3:0 |
Examples
Request example
curl --digest -u 'ak:sk' \
-X GET \
'https://api-cloud.oceanbase.com/api/v2/open/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/samples' \
-G \
-d 'dbName=xxx' \
-d 'startTime=xxx' \
-d 'endTime=xxx'
Response example
JSON format
{
"data": {
"dataList": [
{
"affectedRows": 0,
"blockCacheHit": 0.0,
"blockIndexCacheHit": 0.0,
"bloomFilterCacheHit": 0.0,
"clientIp": "xx.xx.xx.xx",
"clientPort": 19580,
"cpuTime": 1949.68,
"dbName": "test11",
"decodeTime": 0.0,
"diskReads": 0.0,
"elapsedTime": 1956.43,
"executeTime": 1949.66,
"executorRpc": false,
"expectedWorkerCount": 0,
"fullSqlText": "select * from high_disk_read_2 where id > -4413621632286266099 order by id desc limit 1",
"getPlanTime": 0.03,
"hitPlan": true,
"inner": false,
"memstoreReadRows": 0,
"netTime": 0.0,
"netWaitTime": 0.0,
"partitionCount": 1,
"planId": 1049,
"planType": "LOCAL",
"queueTime": 6.75,
"requestId": 369604,
"requestTime": "2025-12-23T06:47:06.207Z",
"retCode": 0,
"retryCount": 0,
"returnRows": 1,
"rowCacheHit": 0.0,
"rpcCount": 0,
"server": "i-uf********",
"sqlId": "5D51DC02208F9A448157FD8A********",
"sqlTextShort": "select * from high_disk_read_2 where id > ? order by id desc limit ?",
"sqlType": "SELECT",
"ssstoreReadRows": 525,
"tableScan": true,
"traceId": "YB420A7100C3-00064694CC824665-0-0",
"transHash": "0",
"usedWorkerCount": 0,
"userClientIp": "xx.xx.xx.xx",
"userName": "test11",
"waitCount": 0,
"waitEvent": "event:, p1text:, p1:0, p2text:, p2:0, p3text:, p3:0"
}
]
},
"requestId": "4c437bbe-d404-4b7a-afcb-88749e4d47a2",
"success": true
}