Overview
You can call this API to query the list of slow SQL statements in a specified time period for a specified OceanBase Cloud instance. You can filter the slow SQL statements by database name, node IP, and SQL keywords. You can also use custom filter conditions to filter the results.
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/instances/{instanceId}/slowSql
Request parameters
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | string | Yes | The ID of the OceanBase Cloud instance. | obcluster-***** |
| requestId | string | Yes | The ID of the request, which is used for tracing. | dc302d76-66b5-48d8-ab53-a035******** |
| startTime | string | Yes | The start time of the query period in the UTC format. | 2026-02-25 15:40:43+00:00 |
| endTime | string | Yes | The end time of the query period in the UTC format. | 2026-02-26 10:40:43+00:00 |
| dbName | string | No | The name of the database. This parameter is used to filter the slow SQL statements in the specified database. | N/A |
| nodeIp | string | No | The IP address of the node. This parameter is used to filter the slow SQL statements in the specified node. | N/A |
| searchKeyWord | string | No | The keyword to be matched in the SQL text. | update |
| sqlTextLength | integer | No | The maximum length of the returned SQL text. The part exceeding this length will be truncated. | 65535 |
| filterCondition | string | No | The custom filter condition. The fields are referenced by using the @ symbol. For example: @avgCpuTime > 20 and @executions > 100. |
@avgCpuTime > 20 and @executions > 100 |
| mergeDynamicSql | boolean | No | Specifies whether to merge dynamic SQL statements. | N/A |
| dynamicSql | boolean | No | Specifies whether to query dynamic SQL statements. | N/A |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| data | array | The list of slow SQL statements. |
| errorCode | string | The error code. |
| message | string | The error message. |
| requestId | string | The ID of the request. |
| server | string | The server address. |
| success | boolean | Indicates whether the request was successful. |
Examples
Request example
curl -X GET \
'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/slowSql?requestId={requestId}&startTime=2026-02-25%2015:40:43%2B00:00&endTime=2026-02-26%2010:40:43%2B00:00&searchKeyWord=update&sqlTextLength=65535&filterCondition=%40avgCpuTime%20%3E%2020%20and%20%40executions%20%3E%20100' \
-H 'Content-Type: application/json' \
-u '<Your AccessKey ID:AccessKey secret>'
Response example
{
"data": [
{
"sqlId": "xxxxxx",
"dbName": "test_db",
"sqlText": "UPDATE test_table SET value = ? WHERE id = ?",
"executions": 150,
"avgCpuTime": 25.5,
"nodeIp": "xxx.xxx.x.xxx"
}
],
"errorCode": "OB-0000",
"message": "success",
"requestId": "xxxxxx",
"server": "xxx.xxx.x.xxx:xxxx",
"success": true
}
