Checking for Slow SQL Statements
Scenarios
Database audit provides a preconfigured rule to check for slow SQL statements, whose response time recorded in audit logs is greater than 1 second.
You can learn the execution duration, number of affected rows, and database information of the slow SQL statements, and optimize the statements accordingly.
- Data Definition Language (DDL):
- CREATE TABLE
- CREATE TABLESPACE
- DROP TABLE
- DROP TABLESPACE
- Data Manipulation Language (DML):
- INSERT
- UPDATE
- DELETE
- SELECT
- SELECT FOR UPDATE
- Data Control Language (DCL):
- CREATE USER
- DROP USER
- GRANT
Checking Slow SQL Statements
Perform the following steps:
- Log in to the management console.
- In the upper part of the page, select a region, click
, and choose Security > Database Security Service. - In the left navigation pane, choose Dashboard.
- In the Instance drop-down list, select the instance whose slow SQL statement information you want to view.
- Click the Statements tab.
- Set filter criteria to query SQL statements.
- Select Last 30 minutes, 1 hour, 24 hours, 7 days, or 30 days, or click
to set start time and end time. Click Submit to view SQL statements of the specified time range. - Set Risk Severity (the default value in the slow SQL rule is Low) and click Submit.
- Click
next to Advanced Settings, enter required information, and click Submit, as shown in Figure 1. The specified SQL statements are displayed in the list.
A maximum of 10,000 records can be retrieved in a query.
- Select Last 30 minutes, 1 hour, 24 hours, 7 days, or 30 days, or click
- In the row containing the desired slow SQL statement, click Details in the Operation column. See Figure 2.
- In the Details dialog box, view the detailed information about the SQL statement. See Figure 3. Table 1 describes the parameters.
Table 1 SQL statement parameters Parameter
Description
Session ID
ID of an SQL statement, which is automatically generated
Database Instance
Database where an SQL statement is executed
Database Type
Type of the database where an SQL statement is executed
Database User
Database user for executing an SQL statement
Client MAC Address
MAC address of the client where an SQL statement is executed
Database MAC Address
MAC address of the database where an SQL statement is executed
Client IP Address
IP address of the client where an SQL statement is executed
Database IP Address
IP address of the database where an SQL statement is executed
Client Port
Port of the client where an SQL statement is executed
Database Port
Port of the database where the SQL statement is executed
Client Name
Name of the client where an SQL statement is executed
Operation Type
Type of an SQL statement operation
Operation Object Type
Type of an SQL statement operation object
Response Result
Response to an SQL statement
Affected Rows
Number of rows affected by executing an SQL statement
Started
Time when an SQL statement starts to be executed
Ended
Time when the SQL statement execution ends
SQL Statement
Name of an SQL statement
Request Result
Result of requesting for executing an SQL statement
Managing Slow SQL Detection Settings
Choose Rules and click the Risky Operations tab. Here you can perform the following operations:
- Enable
In the row containing the slow SQL detection rule, click Enable in the Operation column.
- Edit
In the row containing the slow SQL detection rule, click Edit in the Operation column.
- Disable
In the row containing the slow SQL detection rule, click Disable in the Operation column. Disabled rules will not be audited.
- Delete
In the row containing the slow SQL detection rule, click Delete in the Operation column. To add the rule again, follow the instructions in Adding Risky Operations.
Last Article: Checking Audit Results
Next Article: Checking for Data Reduction



Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.