Slow query logs

更新时间:
复制 MD 格式

Database Autonomy Service (DAS) collects and analyzes SQL statements whose execution duration exceeds a specified threshold, helping you quickly identify and resolve slow query issues that affect database stability and performance.

Background

Slow query logs are generated by the database kernel. Configuration parameters and thresholds vary by database engine. For details, refer to the official documentation for your database engine.

Procedure

  1. Log on to the DAS console.

  2. In the navigation pane on the left, click Intelligent O&M Center > Instance Monitoring .

  3. Find the target instance and click the instance ID to open the instance details page.

  4. In the left-side navigation pane, click Request Analysis > Slow Logs.

  5. Select a time range to view the Slow Log Trend, Event Distribution, Slow Log Statistics, and Slow Log Details.

    • Click the Compute Node (CN) or Data Node (DN) tab to view slow query logs for the respective nodes.

    • In the Slow Log Trend chart, you can select a specific point in time to view the corresponding Slow Log Statistics and Slow Log Details.

      Note

      If a slow SQL statement is too long to be fully displayed, hover the pointer over the statement to view the complete text in a pop-up window.

    • In the Node ID drop-down list, view the number of slow requests for each node.

    • On the Slow Query Log Statistics and Slow Query Log Details tabs, click image to save the slow query log information to a local file.

    • Click image to go to OpenAPI Explorer and debug the API. The currently selected and entered parameters are passed automatically.

    • In the Event Distribution section, you can find slow log events within the specified time range. Click an event to view its details.

    • In the Slow Log Statistics section, find the target SQL template and click Details in the Actions column to view a Slow Log Sample .

      • In the Actions column for the target SQL template, click Optimize. In the SQL Diagnostic Optimization dialog box, view the SQL diagnosis results.

        If you accept the suggestion, click Copy in the upper-right corner and paste the optimized SQL statement into a database client or DMS to run it. If you do not accept the suggestion, click Cancel to close the dialog box.

        Note

        DAS diagnoses SQL statements based on their complexity, the data volume of related tables, and the database load. The diagnosis may take more than 20 seconds to complete. Once complete, the SQL diagnostics engine provides a result, an optimization suggestion, and the expected performance improvement. You can then decide whether to accept the suggestion.

      • In the Actions column for the target SQL template, click Throttling. On the SQL Throttling page, configure throttling parameters for the target SQL statement. For more information, see SQL throttling.

    • Click Logical SQL Statements in the Actions column for the target SQL statement to view the corresponding SQL executed on the Compute Node (CN) or Data Node (DN).

FAQ