Overview
You can call this API to compare the performance data of the top SQL statements executed in a specified time period and in a baseline time period in an OceanBase Cloud database instance and tenant.
API details
Constraints
The caller must have an AccessKey for accessing APIs. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
GET /api/v2/instances/{instanceId}/tenants/{tenantId}/topSqlComparision
Request parameters
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | string | Yes | The ID of the OceanBase Cloud database instance. | obcluster-***** |
| tenantId | string | Yes | The ID of the tenant. | t4louaeei**** |
| requestId | string | Yes | The ID of the request. This parameter is used for tracing. | dc302d76-66b5-48d8-ab53-a035******** |
| startTime | string | Yes | The start time of the target time period in UTC format. | 2026-02-25 15:40:43+00:00 |
| endTime | string | Yes | The end time of the target time period in UTC format. | 2026-02-26 10:40:43+00:00 |
| baseLineStartTime | string | Yes | The start time of the baseline time period in UTC format. | 2026-02-24 15:40:43+00:00 |
| baseLineEndTime | string | Yes | The end time of the baseline time period in UTC format. | 2026-02-25 10:40:43+00:00 |
| server | string | No | The IP address of the server. | xxx.xxx.x.xxx:xxxx |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| data | object | The data of the comparison result. |
| data.comparisionList | array | The list of SQL comparison results. |
| data.comparisionList[].sqlId | string | The unique ID of the SQL statement. |
| data.comparisionList[].sqlText | string | The text of the SQL statement. |
| data.comparisionList[].executions | integer | The number of times the SQL statement was executed in the target time period. |
| data.comparisionList[].baselineExecutions | integer | The number of times the SQL statement was executed in the baseline time period. |
| data.comparisionList[].avgElapsedTime | number | The average execution time of the SQL statement in the target time period. Unit: microseconds. |
| data.comparisionList[].baselineAvgElapsedTime | number | The average execution time of the SQL statement in the baseline time period. Unit: microseconds. |
| data.comparisionList[].elapsedTimeChange | number | The change in the average execution time (target value - baseline value). |
| data.comparisionList[].elapsedTimeChangeRate | number | The change rate of the average execution time ((target value - baseline value) / baseline value). |
| data.comparisionList[].avgCpuTime | number | The average CPU time of the SQL statement in the target time period. Unit: microseconds. |
| data.comparisionList[].baselineAvgCpuTime | number | The average CPU time of the SQL statement in the baseline time period. Unit: microseconds. |
| data.comparisionList[].cpuTimeChange | number | The change in the average CPU time (target value - baseline value). |
| data.comparisionList[].cpuTimeChangeRate | number | The change rate of the average CPU time ((target value - baseline value) / baseline value). |
| data.comparisionList[].avgDiskReads | number | The average number of disk reads in the target time period. |
| data.comparisionList[].baselineAvgDiskReads | number | The average number of disk reads in the baseline time period. |
| data.comparisionList[].diskReadsChange | number | The change in the average number of disk reads (target value - baseline value). |
| data.comparisionList[].diskReadsChangeRate | number | The change rate of the average number of disk reads ((target value - baseline value) / baseline value). |
| data.comparisionList[].server | string | The IP address of the server where the SQL statement was executed. |
| requestId | string | The ID of the request. This parameter is the same as the input parameter. |
| success | boolean | Indicates whether the request was successful. |
Examples
Request example
curl -X GET \
'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/topSqlComparision?requestId={requestId}&startTime={startTime}&endTime={endTime}&baseLineStartTime={baseLineStartTime}&baseLineEndTime={baseLineEndTime}&server={server}' \
-H 'Content-Type: application/json' \
-u '<Your AccessKey ID:AccessKey secret>'
Response example
{
"data": {
"comparisionList": [
{
"sqlId": "xxxxxx",
"sqlText": "SELECT * FROM test_table WHERE id = ?",
"executions": 1500,
"baselineExecutions": 1200,
"avgElapsedTime": 123.45,
"baselineAvgElapsedTime": 100.00,
"elapsedTimeChange": 23.45,
"elapsedTimeChangeRate": 0.2345,
"avgCpuTime": 80.10,
"baselineAvgCpuTime": 70.00,
"cpuTimeChange": 10.10,
"cpuTimeChangeRate": 0.1443,
"avgDiskReads": 5.2,
"baselineAvgDiskReads": 4.0,
"diskReadsChange": 1.2,
"diskReadsChangeRate": 0.3,
"server": "xxx.xxx.x.xxx:xxxx"
}
]
},
"requestId": "xxxxxx",
"success": true
}
