In DRDS, SQL statements that are executed for more than 1 second are defined as slow SQL queries. Slow SQL queries consist of logical and physical slow SQL queries. This topic describes the definitions and query methods of the two types of slow SQL queries.

Background information

The following definitions of logical and physical slow SQL queries are provided:

  • Logical slow SQL queries: slow SQL queries that are sent from a client to DRDS.
  • Physical slow SQL queries:slow SQL queries that are sent from DRDS to the storage layer MySQL.

Eachnode of DRDS saves the details about a maximum of 5,000 slow SQL queries. The details about extra slow SQL queries are deleted in a rolling way.

Procedure

  1. Log on to the DRDS console.
  2. In the top navigation bar, select the region where the target instance is located.
  3. In the left-side navigation pane, click Instances.
  4. Find the target instance and click the instance ID to go to the Basic Information page.
  5. To view details about logical slow SQL queries, perform the following steps:
    1. In the left-side navigation pane, click Slow SQL Queries.
    2. Specify Select Time Range, Database Name, and Execution Time, and then click Search to view information about slow SQL queries.
      Query logical slow SQL queries
    3. Specify Select Time Range, Database Name, and Execution Time, and then click Search to view information about slow SQL queries.
  6. In DRDS, locate the logical slow SQL queries. You can also find the information about the corresponding physical slow SQL queries at the storage layer MySQL by performing the following steps:
    Note Only physical slow SQL queries in PolarDB for MySQL that serves as the storage layer can be queried.
    1. In the left-side navigation pane, click Databases. Select the required database.
    2. Click Storage Management and select the required cluster. The Overview page of MySQL at the storage layer appears.
    3. In the left-side navigation pane, click Slow SQL Query.
    4. To query Slow Log Trend, Slow Log Statistics, and Slow Log Details within a specified time range, specify time in the upper-right corner and click Search.
    5. Click Slow Log Details and select the required database and the primary node to view details about slow query logs.
      View physical slow query logs
      Note For more information about slow SQL analysis and diagnostics features, see Slow SQL queries.