Suspicious SQL statements are statements that meet specific criteria based on the statement, execution history, and table structure and may cause performance issues. You can handle suspicious SQL statements based on the suggestions given.
Procedure
You can diagnostics suspicious SQL by using one of the following methods.
Method 1:
Log on to the OceanBase Cloud Platform (OCP) console.
In the left-side navigation pane, click Autonomous Services to go to the Real-time Diagnostics page.
The SQL Diagnostics page automatically appears.
Method 2:
Log on to the OceanBase Cloud Platform (OCP) console.
To go to the O&M page of the tenant.
In the left-side navigation pane, click SQL Diagnostics to go to the SQL Diagnostics page.
The following takes Method 1 as an example.
Log on to the OceanBase Cloud Platform (OCP) console.
In the left-side navigation pane, click Autonomous service.
In the Cluster Details section, click the name of the target cluster.
By default, the SQL Diagnostics tab of the Real-time Diagnostics page appears.
The SQL diagnostic data is not displayed on the SQL Diagnostics page if you do not set the values of both the cluster parameter enable_sql_audit and the tenant parameter ob_enable_sql_audit to True. You can click Change Cluster Parameters in the prompt to modify the parameter values.

Click the Suspected SQL tab.
Filter the suspicious SQL statements.
- Specify the filter conditions.
Time Range: You can select Last 5 Minutes, Last 10 Minutes, Last 20 Minutes, Last 30 Minutes, Last 1 Hour, or Last 3 Hours from the Time Range drop-down list. You can also select Custom Time from the drop-down list and specify the start time and end time as needed. By default, the information of the last 30 minutes is displayed.
Internal SQL: If you select this option, the SQL statements internally initiated in OceanBase Database are displayed in the query result.
Keyword: The SQL statements that contain the specified keyword are displayed in the query result. The keywords filter SQL statements in the same way as the SQL Like operator. The entered strings are automatically prefixed and suffixed with a percent sign (%).
Advanced Search: You can add multiple filter conditions in Advanced Search . Click Add . In the Add Advanced Condition dialog box, you can specify a metric, an operator, and a metric value. The SQL statements that match the specified criteria will be displayed in the query result.
- Click Search to list all SQL statements that meet the search criteria.
You can copy the SQL text and view the diagnosis result. You can also filter the SQL statements by database, and then sort the suspicious SQL statements by the number of executions, average response time, average CPU time, and plan generation time.

Click Export Suspicious SQL Statements to export all suspicious SQL statements in the query result.
View the information of suspicious SQL statements.
You can click the SQL text of an SQL statement to go to the SQL Details page of the statement. On the SQL Details page, you can view the following details of the SQL statement:
In the SQL Text section, you can view the complete SQL statement.
In the Optimization Suggestions section, you can view the optimization suggestions for the SQL statement. For more information, see View optimization suggestions.
View diagnosis result: You can view the diagnosis result for a specified time range.
The following table describes some diagnoses and their suggested solutions.
Diagnosis Related parameter Index analysis required SQL risk level Description and suggestion After the execution plan was modified, the performance of the SQL statement was deteriorated. ocp.perf.sql-diag.performance-degradation-after-plan-changed-configNo High The execution plan of the SQL statement was modified, and the performance of the SQL statement was deteriorated. Check with the database administrator (DBA). You can use an outline to fix the execution plan and verify whether the SQL statement is problematic. Table scan without available index ocp.perf.sql-diag.table-scan-index-not-exists-configYes High During the execution of the SQL statement, a full table scan was performed on some related tables because they did not have indexes available. We recommend that you create appropriate indexes. Table scan with unused index ocp.perf.sql-diag.table-scan-index-not-exists-configYes High All tables involved in the execution of the SQL statement are indexed. However, a full table scan was performed on some of these tables because their indexes were not used. Check the data distribution and business scenario. Hints did not take effect. ocp.perf.sql-diag.ineffective-hint-configYes High An index was specified in the hint of the SQL statement, but the specified index was not used during execution. Check whether the hint of the SQL statement matches the actual execution plan. Deteriorated performance ocp.perf.sql-diag.performance-degradation-configNo Medium During the diagnosis period, the average CPU time consumed to execute the SQL statement is longer than the historical average. Check the changes in data distribution and the queuing status in the tenant. Poor performance despite the use of indexes ocp.perf.sql-diag.awful-performance-index-used-configYes Medium The index was used for table access during the execution of the SQL statement, but the performance was poor. Check the data distribution and business scenario. Execution spikes ocp.perf.sql-diag.execution-spike-configNo Medium The executions of the SQL statement suddenly increased during a specific period of time. You can view the number of executions on the Previous Tendency tab of the SQL Details page. Check the business volume. A spike in the number of executions of an SQL statement may cause the overall performance to deteriorate. Row lock contention ocp.perf.sql-diag.row-lock-contention-high-configNo Medium Check your business scenarios, to determine whether the SQL statements of the select for updatetype were executed more frequently than the specified threshold, and whether the CPU time was greater than the specified threshold.CPU utilization exceeds the threshold ocp.perf.sql-diag.cpu-time-proportion-high-configNo Low The CPU time occupancy of the SQL statement was too high during the diagnosis period. CPU time occupancy = CPU time for executing the SQL statement/CPU time for executing all SQL statements of the tenant * 100%. Check your business scenarios, data distribution changes, request surges, and execution plan changes. By default, SQL diagnostics is triggered in OceanBase Cloud Platform (OCP) only when some attributes such as the SQL response time and execution frequency exceed the specified thresholds. You can modify default values of specific parameters on the System Parameters page of OCP, to specify the objects and criteria for diagnostics. For information about the parameter, see OCP configuration parameters.
On the Previous Tendency tab, you can view the historical trends of the SQL statement. For more information, see View the historical trends of an SQL statement.
On the Execution Plans tab, you can view the execution plans of the SQL statement, or bind an execution plan to the statement. For more information, see View the execution plans of an SQL statement.
On the Index tab, you can view the indexes bound to the SQL statement. For more information, see View and bind indexes.
On the SQL Throttling tab, you can view or set throttling of the SQL statement. For more information, see Set SQL throttling.
You can view the binding records of the SQL statement in section ① as illustrated on the Execution Plans , Index , and SQL Throttling tabs.
In the binding records, you can view the status of a bound execution plan, or click Unbind to unbind the plan from the SQL statement. You can click Bind Plan to bind the plan to the SQL statement again.

Set throttling.
You can click Enable Throttling to enable throttling for the SQL statement. For more information, see Set SQL throttling.
Select multiple SQL statements and click Batch Set Throttling . In the dialog box that appears, specify the maximum number of SQL statements that can be executed concurrently.