Overview
You can call this API to query the SQL execution history.
API details
Constraints
The caller must have an AccessKey for accessing the APIs. 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}/trends
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 |
|---|---|---|---|---|
| startTime | Long | No | The start time. | 2025-01-01T00:00:00Z |
| endTime | Long | No | The end time. | 2025-01-02T00:00:00Z |
| dbName | String | No | The name of the database. | test11 |
| nodeIp | String | No | The IP address of the node. | xx.xx.xx.xx |
| dynamicSql | Boolean | No | Specifies whether the SQL statement is dynamic. | true |
Response parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| data | Object | Data. | {} |
| dataList | Array | Data list. | [] |
| avgAffectedRows | Double | Average number of rows updated during the period. | 0.0 |
| avgApplicationWaitTime | Double | Average Application event wait time during the period (in milliseconds). | 0.0 |
| avgBlockCacheHit | Double | Average number of BlockCache hits during the period. | 0.0 |
| avgBlockIndexCacheHit | Double | Average number of BlockIndexCache hits during the period. | 0.0 |
| avgBloomFilterCacheHit | Double | Average number of BloomFilterCache hits during the period. | 0.0 |
| avgConcurrencyWaitTime | Double | Average Concurrency event wait time during the period. | 0.0 |
| avgCpuTime | Double | Average CPU time during the period (in milliseconds). | 444.86 |
| avgDbTime | Double | Average database time (in milliseconds). | 444.87 |
| avgDecodeTime | Double | Average syntax parsing time during the period (in milliseconds). | 0.0 |
| avgDiskReads | Double | Average number of physical reads during the period. | 0.0 |
| avgElapsedTime | Double | Average response time during the period (in milliseconds). | 450.71 |
| avgExecuteTime | Double | Average plan execution time during the period (in milliseconds). | 444.82 |
| avgExecutorRpcCount | Double | Average number of executed RPC requests during the period. | 0.0 |
| avgGetPlanTime | Double | Average plan generation time during the period (in milliseconds). | 0.04 |
| avgLogicalReads | Double | Average number of logical reads. | 0.0 |
| avgMemstoreReadRows | Double | Average number of Memstore reads during the period. | 0.0 |
| avgNetTime | Double | Average network transmission time during the period (in milliseconds). | 0.0 |
| avgNetWaitTime | Double | Average network enqueue time during the network wait period (in milliseconds). | 0.0 |
| avgPartitionCount | Double | Average number of partitions during the period. | 1.0 |
| avgQueueTime | Double | Average queueing time during the period (in milliseconds). | 5.85 |
| avgReturnRows | Double | Average number of returned rows during the period. | 0.52 |
| avgRowCacheHit | Double | Average number of RowCache hits during the period. | 0.0 |
| avgRpcCount | Double | Average number of RPC requests during the period. | 0.0 |
| avgScheduleTime | Double | Average Schedule event wait time during the scheduling period (in milliseconds). | 0.0 |
| avgSsstoreReadRows | Double | Average number of SsStore reads during the period. | 271.99 |
| avgUserIoWaitTime | Double | Average UserIO event wait time during the period (in milliseconds). | 0.0 |
| avgWaitCount | Double | Average number of waits during the period. | 0.0 |
| avgWaitTime | Double | Average wait time during the period (in milliseconds). | 0.0 |
| dbName | String | Database name. | test11 |
| distPlanPercentage | Double | Percentage of distributed plans. | 0.0 |
| execPs | Double | Percentage of executed PS. | 4.15 |
| executions | Long | Number of executions. | 249 |
| failCount | Long | Number of failed executions. | 0 |
| failPercentage | Double | Failure percentage. | 0.0 |
| localPlanPercentage | Double | Percentage of local plans. | 100.0 |
| maxCpu Time | Double | Maximum CPU time (in milliseconds). | 1949.68 |
| maxElapsedTime | Double | Maximum response time (in milliseconds). | 1956.43 |
| missPlanPercentage | Double | Percentage of missed plans. | 0.0 |
| missPlans | Long | Number of missed plans. | 0 |
| remotePlanPercentage | Double | Percentage of remote plans. | 0.0 |
| remotePlans | Long | Number of remote plans. | 0 |
| retCode4012Count | Long | Number of times return code 4012 is returned. | 0 |
| retCode4013Count | Long | Number of times return code 4013 is returned. | 0 |
| retCode5001Count | Long | Number of times return code 5001 is returned. | 0 |
| retCode5024Count | Long | Number of times return code 5024 is returned. | 0 |
| retCode5167Count | Long | Number of times return code 5167 is returned. | 0 |
| retCode5217Count | Long | Number of times return code 5217 is returned. | 0 |
| retCode6002Count | Long | Number of times return code 6002 is returned. | 0 |
| retryCount | Long | Number of retries. | 0 |
| server | String | Server name. | i-uf******** |
| serverIp | String | Server IP address. | xx.xx.xx.xx |
| strongConsistencyPercentage | Double | Percentage of strong consistency. | 100.0 |
| sumDbTime | Double | Total database time (in milliseconds). | 110771.68 |
| sumElapsedTime | Double | Total response time (in milliseconds). | 112227.44 |
| sumLogicalReads | Double | Total number of logical reads. | 0.0 |
| sumWaitTime | Double | Total wait time (in milliseconds). | 0.0 |
| tableScanPercentage | Double | Percentage of table scans. | 100.0 |
| timestamp | String | Timestamp. | 2025-12-23T06:48:08Z |
| userName | String | Username. | test_mysql |
| waitEvent | String | Wait event. | none |
| weakConsistencyPercentage | Double | Percentage of weak consistency. | 0.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}/trends' \
-G \
-d 'startTime=xxx' \
-d 'endTime=xxx' \
-d 'dbName=xxx' \
-d 'nodeIp=xxx' \
-d 'dynamicSql=xxx'
Response example
JSON format
{
"data": {
"dataList": [
{
"avgAffectedRows": 0.0,
"avgApplicationWaitTime": 0.0,
"avgBlockCacheHit": 0.0,
"avgBlockIndexCacheHit": 0.0,
"avgBloomFilterCacheHit": 0.0,
"avgConcurrencyWaitTime": 0.0,
"avgCpuTime": 444.86,
"avgDbTime": 444.87,
"avgDecodeTime": 0.0,
"avgDiskReads": 0.0,
"avgElapsedTime": 450.71,
"avgExecuteTime": 444.82,
"avgExecutorRpcCount": 0.0,
"avgGetPlanTime": 0.04,
"avgLogicalReads": 0.0,
"avgMemstoreReadRows": 0.0,
"avgNetTime": 0.0,
"avgNetWaitTime": 0.0,
"avgPartitionCount": 1.0,
"avgQueueTime": 5.85,
"avgReturnRows": 0.52,
"avgRowCacheHit": 0.0,
"avgRpcCount": 0.0,
"avgScheduleTime": 0.0,
"avgSsstoreReadRows": 271.99,
"avgUserIoWaitTime": 0.0,
"avgWaitCount": 0.0,
"avgWaitTime": 0.0,
"dbName": "test11",
"distPlanPercentage": 0.0,
"execPs": 4.15,
"executions": 249,
"failCount": 0,
"failPercentage": 0.0,
"localPlanPercentage": 100.0,
"maxCpuTime": 1949.68,
"maxElapsedTime": 1956.43,
"missPlanPercentage": 0.0,
"missPlans": 0,
"remotePlanPercentage": 0.0,
"remotePlans": 0,
"retCode4012Count": 0,
"retCode4013Count": 0,
"retCode5001Count": 0,
"retCode5024Count": 0,
"retCode5167Count": 0,
"retCode5217Count": 0,
"retCode6002Count": 0,
"retryCount": 0,
"server": "i-uf********",
"serverIp": "xx.xx.xx.xx",
"strongConsistencyPercentage": 100.0,
"sumDbTime": 110771.68,
"sumElapsedTime": 112227.44,
"sumLogicalReads": 0.0,
"sumWaitTime": 0.0,
"tableScanPercentage": 100.0,
"timestamp": "2025-12-23T06:48:08Z",
"userName": "test_mysql",
"waitEvent": "none",
"weakConsistencyPercentage": 0.0
}
],
"total": 1
},
"requestId": "87b69bed-98e9-455d-a68d-268105d3a954",
"success": true
}