Suspected SQL statements are statements that meet some criteria based on the statement, execution history, and table structure and may cause performance issues. You can handle suspected SQL statements based on the recommendation given.
Procedure
In the left-side navigation pane, click Tenants and click a tenant in the Tenants list to go to the Overview page of the tenant.
In the left-side navigation pane, click SQL Diagnosis . The SQL Diagnosis page appears.
The SQL diagnostic data is not displayed on the SQL Diagnosis 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 box to modify the parameter values.
Click the Suspected SQL tab.
Filter the suspected SQL statements.
Specify the filter conditions.
Time Range: You can select the last 5 minutes, last 10 minutes, last 20 minutes, last 30 minutes, last 1 hour, and last 3 hours from the drop-down list of the Duration . 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 by OceanBase Database are displayed in the query result.
Keywords: The SQL statements that contain the specified keywords 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 select SQL ID, Executions, and Executions per Second from the drop-down list, and specify the values. The SQL statements matching the metric values are displayed in the query result.
Click Search to list all the SQL statements that meet the filter conditions.
Click Export Suspected SQLs to export all the suspected SQL statements in the query result.
View the information of suspected SQL statements.
On the Suspected SQL tab, you can copy the SQL text, filter it by database, sort it by the number of executions, average CPU time, average response time, total response time, and last execution time, and view the diagnosis result.
You can click the SQL text to go to the corresponding SQL text page.
On the SQL Details page, you can view the following SQL statement details:
In the SQL Text section, you can view the text of the SQL statement.
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 changed, the performance was decreased. ocp.perf.sql-diag.performance-degradation-after-plan-changed-configNo High The execution plan of the SQL statement was changed, and the performance of the new plan was decreased. Check with the DBA. You can use an outline to fix the execution plan to verify whether the SQL statement is problematic. Full table scan was performed because some tables had no indexes. 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. Full table scan was performed because the indexes of some tables were not used. 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. The performance becomes lower. ocp.perf.sql-diag.performance-degradation-configNo Medium During the diagnostic period, the average CPU time consumed for the execution of the SQL statement is longer than the historical average. Check the changes in data distribution and the queue in the tenant. Indexes were used but the performance was still low. 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 certain period. You can view the number of executions in the Historical Trends tab of the SQL Details . Check the business volume. A spike in the number of executions of an SQL statement may cause the overall performance to decrease. Row lock contention exists. ocp.perf.sql-diag.row-lock-contention-high-configNo Medium Check your business scenarios, whether the SQL statements of the select for updatetype were executed more frequently than the specified value, and whether the CPU time was greater than the specified value.The proportion of CPU time consumed for executing the current SQL is too high. ocp.perf.sql-diag.cpu-time-proportion-high-configNo Low The CPU utilization was too high during the diagnostic period. The CPU utilization = 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 increases, and execution plan changes. You can search for a parameter from the System Parameters of OCP, and modify the default parameter value to customize the target and criteria for the diagnosis. For more information, see SQL performance module.
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 plan 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 a binding record, you can view the status of the bound execution plan, click Unbind to unbind the plan from the SQL statement, and click Bind Plan to bind the plan to the SQL statement again.