Suspicious SQL typically refers to SQL statements executed in the database that have potential risks or abnormal behaviors. OceanBase Cloud will display abnormal SQL executions, providing clearer guidance for your SQL optimization.
View the suspicious SQL list
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.
In the left-side navigation pane, click Diagnostics, and then select the Real-Time Diagnostics tab on the Diagnostics page.
On the SQL tab, select Suspicious SQL.
(Optional) Configure filter conditions.
Database: Select any database in the current cluster.
Node: Select any node in the current database.
Time range: View the data of the Last 5 Minutes, Last 30 Minutes, Last 1 Hour, Last 3 Hours, or Last 6 Hours. You can also customize the time range (up to 15 days), but please 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 keyword of the SQL text to be queried, and the query results will display the SQL containing the keyword in the SQL text. Constant search is not supported.
- More conditions: Click +Add, and in the Add More Conditions panel, configure the metric, operator, and value. When querying, the SQL that satisfies the metric conditions will be displayed in the query result list.
Click Query.
The Suspicious SQL tab displays the following metrics by default: 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.
Filter SQL text by Tenant Name and Database.
Sort SQL text by Total Number of Executions, Total Database Time (ms), Average Time (ms), CPU Time (ms), and Logical Reads.
Check the Aggregation In Query in the upper right corner of the list to display the SQL by aggregate in, without affecting the statistical data.
Note
Aggregation in queries refers to ignoring the number of constant parameters in the IN clause of an SQL statement, and uniformly treating each IN clause as having only one constant parameter. According to this rule, the SQL statement is parameterized and the SQL ID is calculated. SQL statements with the same SQL ID are considered to be of the same type and are aggregated.
Click ..., and then click Download Table to download the suspicious SQL list.
Click the icon
to query more metrics in the Manage Columns window that pops up.