Help Center/ Data Admin Service/ Best Practices/ Fixing Slow SQL Queries
Updated on 2024-10-28 GMT+08:00

Fixing Slow SQL Queries

You can use DAS to monitor databases and identify and fix slow SQL queries to improve database performance.

Viewing and Optimizing Slow SQL Statements of a Single Instance

  1. Log in to the DAS console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane, choose Intelligent O&M > Instance List.

    Alternatively, on the Overview page, click Go to Intelligent O&M.

  5. In the upper right corner of the instance list, filter instances by engine, name, or IP address. Click Details to go to the Dashboard tab page.

    Figure 1 Intelligent O&M

  6. Choose SQL > Slow Query Logs.

    Select a time range and view trends, details, and statistics of the slow query logs. You can click Export to export a slow query log to your local PC.

    Figure 2 Slow Query Logs

  7. In the Details area, click Concurrency Control in the Operation column. In the displayed dialog box, create a concurrency control rule for the current SQL statement by configuring parameters, including Max. Concurrency to ensure stability of core services. For details, see SQL Statement Concurrency Control.

    Figure 3 Concurrency control

  8. In the Details area, click Diagnose in the Operation column to diagnose the current SQL statement and view index or statement optimization suggestions and an execution plan. You can paste optimized SQL statement to the database client or DAS for execution. For details, see SQL Diagnosis.

    Figure 4 Diagnosis

Viewing Slow SQL Queries on All Instances

  1. Log in to the DAS console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane, choose Intelligent O&M > Dashboard.

    Select a time range and view the number of slow SQL queries of the top 10 to 30 instances in the current region. You can also view information about the slow SQL template of an instance.

    Figure 5 Overview of slow SQL queries