Description
You can call this operation to query performance indicators of an execution plan associated with a specified SQL statement.
Call description
Prerequisite
You have the Read-only permission on the specified tenant.
Request path
GET /api/v2/ob/clusters/{clusterId}/tenants/{tenantId}/sqls/{sqlId}/topPlan
Request parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| clusterId | Integer | Yes | 1 | The ID of the cluster. |
| tenantId | Integer | Yes | 1001 | The ID of the tenant. |
| sqlId | String | Yes | C9B3A63AFF8F2A408CCF3D5B0F36682D | The ID of the SQL statement. |
| startTime | Datetime | Yes | 2020-02-16T05:32:16+08:00 | The start time. |
| endTime | Datetime | Yes | 2020-02-16T07:32:16+08:00 | The end time. |
| serverId | Integer | No | 300 | Specifies the ID of the OBServer on which you want to query the performance indicators of an execution plan. If it is not specified, the system queries the performance indicators of the SQL execution plan on all OBServers. |
Response parameters
Basic data structure
Parameter Type Description data Object The requested data. ├─ contents Array The array of the detailed information of the plan. For more information about its data structure, see the following table. successful Boolean Indicates whether the request was successful. timestamp Datetime The timestamp when the server completed the request. duration Integer The time taken by the server to process the request, in milliseconds. status Integer An HTTP status code. traceId String The trace ID of the request. This trace ID is used for troubleshooting. server String The address of the application server that responded to the request.
Data structure of plan details
Parameter Type Description uid String The UID of the plan. server String The URL of the OBServer, including IP address and port. planId Integer The original ID of the plan. It is an auto-increment value in the OBServer scope. firstLoadTime Datetime The first load time of the plan. planType String The type of the plan. Valid values: * LOCAL: local plan. * REMOTE: remote plan. * DIST: distributed plan. planHash Integer The hash value of the plan. planSize Integer The size of the plan. schemaVersion Integer The schema version. mergedVersion Integer The major compaction version. hitPercentage Float The plan retrieval rate during the execution period of the plan. executions Integer The total number of times the plan was executed during its execution period. execPs Float The average number of times the plan was executed every second during its execution period. maxExecTime Float The longest plan execution time during the execution period of the plan, in milliseconds. avgDiskReads Float The average disk read times during the execution period of the plan. avgDiskWrites Float The average disk write times during the execution period of the plan. avgBufferGets Float The average cache read times during the execution period of the plan. avgApplicationWaitTime Float The average Application wait time during the execution period of the plan, in milliseconds. avgConcurrencyWaitTime Float The average Concurrency wait time during the execution period of the plan, in milliseconds. avgUserIoWaitTime Float The average UserIO wait time during the execution period of the plan, in milliseconds. avgRowProcessed Float The average rows processed during the execution period of the plan. avgElapsedTime Float The average response time during the execution period of the plan. avgCpuTime Float The average CPU time during the execution period of the plan. largeQueryPercentage Float The percentage of large queries during the execution period of the plan. delayedLargeQueryPercentage Float The percentage of queued large queries during the execution period of the plan. timeoutPercentage Float The percentage of timed out executions during the execution period of the plan. tableScan Boolean Indicates whether the full table scan was included in the plan.
Examples
Sample request
Query all physical execution plans of an SQL statement with an ID of 520A740747059F992A31CE41876BB161 based on the cluster ID 1 and tenant ID 1, and set the time range to 2020-11-11T11:30:00+08:00 to 2020-11-11T12:00:00+08:00.
GET /api/v2/ob/clusters/1/tenants/1/sqls/520A740747059F992A31CE41876BB161/topPlan?startTime=2020-11-11T11%3A30%3A00%2B08%3A00&endTime=2020-11-11T12%3A00%3A00%2B08%3A00