Performance analysis

更新时间:
复制 MD 格式

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

  1. Log on to the Database Audit Service console. For more information, see Log on to the Database Audit Service console.

  2. In the left-side navigation pane, choose Query and Analysis > Audit Logs.

Step 2: View top SQL statements

  • Top SQL by average duration, count, and total duration

    1. 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.

      Filters and descriptions

      Filter

      Description

      Time range

      The query time range for the audit logs.

      Asset

      The asset or asset group to query.

      In the Asset drop-down list, select one or more assets or asset groups from the Select Asset or Select Asset Group tab, and then click OK.

      Number of top entries

      The number of top entries to display. Supported options include:

      • 10

      • 20 (Default)

      • 50

      • 100

      Average execution duration (μs)

      The average execution duration of SQL statements.

      Execution count

      The number of times a SQL statement was executed.

      Total execution duration (μs)

      The total execution duration of a SQL statement.

      • 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.

    2. 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

    1. 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.

      Filters and descriptions

      Filter

      Description

      Time range

      The query time range for the audit logs.

      Asset

      The asset or asset group to query.

      In the Asset drop-down list, select one or more assets or asset groups from the Select Asset or Select Asset Group tab, and then click OK.

      Number of top entries

      The number of top entries to display. Supported options include:

      • 10

      • 20 (Default)

      • 50

      • 100

      Execution duration (μs)

      The execution duration of a single SQL statement.

      • 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.

    2. 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.