This topic explains how to query top SQL statements using the performance analysis feature of a Database Audit Service C100 instance.
Top SQL statements
Databases are often large-scale applications. A busy database consumes significant memory, CPU, I/O, and network resources. A key part of improving database performance is SQL optimization. To optimize your queries, you must first identify the SQL statements that consume the most resources (known as top SQL statements).
Step 1: Log on to the Database Audit Service console
Log on to the Database Audit Service console. For more information, see Log on to the Database Audit Service console.
In the left-side navigation pane, choose .
Step 2: View top SQL statements
Top SQL by average duration, count, and total duration
Set the filter criteria
The search function helps you narrow your query scope. You can set query conditions on the TOP by Average Execution Duration, TOP by Execution Count, and TOP by Total Execution Duration tabs of the TOP SQL tab on the Audit Logs page. The supported filter conditions are described in the following table.
Click the Settings
icon. In the Set Display Columns dialog box, select the columns to display in the results, and then click OK.Click Search to run the query.
View top SQL statements
View the list of results
The TOP SQL Analysis list displays the ranking information for each SQL template. The list includes columns such as Rank, SQL Template, Server IP, Average Execution Duration, Execution Count, and Total Execution Duration.
View audit logs
Click the number in the Execution Count column to view the detailed log information for the SQL template on the Audit Logs tab of the Audit Logs page.
Top SQL by execution duration
Set the filter criteria
You can use the search feature to narrow the scope of your queries by specifying search criteria on the Top Execution Duration tab of the TOP SQL tab on the Audit Logs page. The supported filter conditions are listed in the table below.
Click the Settings
icon. In the Set Display Columns dialog box, select the columns to display in the results, and then click OK.Click Search to run the query.
View top SQL statements by execution duration
View the list of results
The TOP SQL Analysis list displays the ranking information for each SQL statement. The list includes columns such as Rank, SQL Statement, Server IP, Client IP, Client Tool, Database Account, and Execution Duration.
View audit logs
Click the number in the Execution Count column to view the detailed logs for the SQL template on the Audit Logs tab of the Audit Logs page.