Suspicious SQL statements are SQL statements that have potential risks or abnormal behaviors and are executed in the database. OceanBase Cloud displays the abnormal SQL statements to provide clearer guidance for your SQL tuning.
View the list of suspicious SQL statements
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
In the instance list, find the target instance, click the instance name, and go to the Overview page of the instance.
Click Diagnostics in the left-side navigation pane, and then select the Diagnostics page.
On the SQL tab, select Suspicious SQL.
(Optional) Set filter conditions.
Database: Select any database in the current cluster.
Time range: Supports viewing data in the following time ranges: Past 5 Minutes, Past 30 Minutes, Past 1 Hour, Past 3 Hours, and Past 6 Hour(s). You can also customize the time range (up to 15 days), but note the following limitations:
- Maximum range limit: The selected time range must not exceed 24 hours.
- Minimum range limit:
- For data within 3 days: The selected time range must be at least 1 minute.
- For data from 3 to 7 days: The selected time range must be at least 5 minutes.
- For data beyond 7 days: The selected time range must be at least 20 minutes.
SQL ID: Enter the SQL ID to be queried. You can enter multiple IDs and separate them with half-width characters , or ;.
SQL text: Enter the SQL text keyword to be queried. The query results will display the SQL containing the keyword in the SQL text. Constant search is not supported.
More Conditions: Click + Add. In the Add More Conditions panel, configure the metric, operator, and value. When you query, the SQL that satisfies the metric conditions will be displayed in the query result list.
Click Query.
By default, the Suspicious SQL tab displays the following metrics: SQL text, Tenant Name, SQL ID, Database, Diagnostic Results, Total Executions, Total Database Time (ms), Average Time (ms), CPU time (ms), Logical Read, Total Retries, and Average Retries.
You can filter SQL text by Tenant Name and Database.
You can sort SQL text by Total Executions, Total Database Time (ms), Average Time (ms), CPU time (ms), and Logical Read.
Click Aggregation In Query in the upper-right corner of the table to display SQL statements in an aggregated-in manner without affecting the statistics.
Note
Aggregated in Query means that the number of constant parameters in the IN clause of the SQL statement is ignored, and each IN clause is treated as having only one constant parameter. Based on this rule, the SQL statement is parameterized, and the SQL ID is calculated. SQL statements with the same SQL ID are aggregated as the same type.
Click ..., and then click Download Table to download the list of suspicious SQL statements.
Click the icon
to query more metrics in the Manage Columns window that pops up.