Database Autonomy Service (DAS) provides the slow query log analysis feature to help you detect, analyze, diagnose, and track slow query logs of your ApsaraDB for Redis instances. This helps you create appropriate indexes and improves the resource utilization rate of your instance.

Prerequisites

  • A database instance that runs the Redis engine is created.
  • The ApsaraDB for Redis instance is connected to DAS and is in the Accessed state. For information about how to connect an instance to DAS, see Access an Alibaba Cloud database instance.

Background information

The slow query log analysis feature displays slow query log statistics. This helps you identify the most frequently executed slow SQL statement, the most time-consuming slow SQL statement, and the slow query statement that scans the largest average number of rows.

Procedure

By default, the slow query log analysis feature is disabled. To enable this feature, perform the following steps:

  1. In the left-side navigation pane, choose Request Analysis > Slow Logs.
  2. Click the Log Trend tab. The Log Trend tab displays the number of slow query log entries by hour. You can perform the following operations on the Log Trend tab:
    • Click a dot in the chart to view the slow query log details that are collected during a specific period of time.
    • In the Slow Log Statistics section, you can view the slow query log statistics and find the most frequently executed slow SQL statement and the most time-consuming slow SQL statement.
    • Click Sample in the Actions column of a slow query log entry to view the request details such as the slow query log information and the IP address of the client.
    Note
    • By default, the slow query log trend chart for the previous day is displayed. You can also specify a start time and an end time, and click Search to view the slow query log trend within the specified period of time.
    • On the Log Trend tab, you can view the number of slow query logs for the instance by hour.
    • You can click a dot in the trend chart to view the slow query log details of a specified period. The system collects log information only for slow queries whose execution time is greater than 100 milliseconds.

Export slow query log information

To download and save the slow query log data to an on-premises location, you can click Export on the Current Log tab. Alternatively, you can click Export Slow Log on the Log Trend tab.

Global trends of slow query logs

In the left-side navigation pane, choose Request Analysis > Slow Logs. On the page that appears, view the trends of slow query logs in all the database instances that are connected to DAS.