Overview
You can call this API to query SQL tuning advices.
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}/sqls/{sqlId}/tuningAdvices
Request parameters
Path
| Parameter | Type | Required | Description |
|---|---|---|---|
| instanceId | String | Yes | The ID of the instance. |
| tenantId | String | Yes | The ID of the tenant. |
| sqlId | String | Yes | The ID of the SQL statement. |
Query
| Parameter | Type | Required | Description |
|---|---|---|---|
| dbName | String | No | The name of the database. |
| startTime | String | No | The start time. |
| endTime | String | No | The end time. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| data | Object | The SQL tuning advice data. |
| database | String | The name of the database. |
| tenantId | String | The ID of the tenant. |
| type | String | The optimization type. |
| columnNames | String | The order of the indexed columns. |
| dbName | String | The name of the database. |
| table | String | The name of the table. |
| columns | Array | The information about the indexed columns. |
| columnName | String | The name of the column. |
| ndv | Integer | The number of distinct values (NDV). |
| minValue | String | The minimum value. |
| maxValue | String | The maximum value. |
| plan | Object | The execution plan. |
| avgApplicationWaitTime | Integer | The average Application event wait time (in milliseconds) during the period. |
| avgBufferGets | Integer | The average number of buffer gets during the period. |
| avgConcurrencyWaitTime | Integer | The average Concurrency event wait time (in milliseconds) during the period. |
| avgCpuTime | Integer | The average CPU time (in milliseconds) during the period. |
| avgDiskReads | Integer | The average number of physical reads during the period. |
| avgDiskWrites | Integer | The average number of physical writes during the period. |
| avgElapsedTime | Integer | The average interval wait time (in milliseconds) during the period. |
| avgRowProcessed | Integer | The average row processing wait time (in milliseconds) during the period. |
| avgUserIoWaitTime | Integer | The average UserIo event wait time (in milliseconds) during the period. |
| collectTimeUs | Long | The collection time. |
| delayedLargeQueryPercentage | Double | The percentage of queries that are delayed in long-running queries. |
| execPs | Double | The average number of queries executed per second during the period. |
| executions | Long | The total number of queries executed during the period. |
| firstLoadTime | Long | The time when the query was first loaded. |
| firstLoadTimeUs | Long | The time when the query was first loaded. |
| hitDiagnosis | Boolean | Indicates whether the query was diagnosed. |
| largeQueryPercentage | Double | The percentage of queries that are long-running. |
| mergedVersion | Long | The merged version. |
| obDbId | Long | The ID of the database. |
| obServerId | Long | The server ID. |
| outlineData | String | The outline_data field of the SQL execution plan. |
| outlineId | Long | The outline ID. |
| planId | Long | The plan ID. |
| planSize | Long | The size of the plan. |
| planType | String | The plan type: LOCAL, REMOTE, or DIST. |
| server | String | The IP address of the node. |
| serverSn | String | The node ID. |
| tableScan | Boolean | Indicates whether a full table scan was performed. |
| planHash | String | The identifier of the SQL execution plan in the diagnostic system. |
| timeoutPercentage | Double | The percentage of queries that timed out. |
| schemaVersion | Long | The schema version. |
| sqlId | String | The SQL ID. |
| uid | String | The unique identifier of the plan. |
| requestId | String | The ID of the request. |
| success | Boolean | Indicates whether the request was successful. |
Examples
Request example
curl --digest -u 'ak:sk' \
-X GET \
'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/tuningAdvices' \
-G -d 'dbName=testdb' \
-d 'startTime=2025-01-01T00:00:00Z' \
-d 'endTime=2025-01-02T00:00:00Z'
Response example
JSON format
{
"data": {},
"requestId": "xxxxxx",
"success": true
}