PolarDB for MySQL provides the slow SQL analysis feature. This feature allows you to view slow log trends and statistics. You can also obtain the diagnostic results and suggestions on how to fix slow SQL queries.

Prerequisites

The service edition of your PolarDB for MySQL clusters is Cluster Edition or Archive Database. This feature is unavailable for Single Node. For more information about service editions, see Product editions.

View slow log trends and statistics

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region where the cluster is deployed.
  3. Find the cluster and click the cluster ID.
  4. In the left-side navigation pane, choose Diagnostics and Optimization > Slow SQL Query.
  5. In the Slow Log Trend section, use one of the following methods to view slow log trends:
    • Click Last 15 Minutes, 30 Minutes, or 1 Hour to view the slow log trends within the last 15 minutes, the last 30 minutes, or the last hour.
    • Specify the date range and click Search to view the slow log trend within at most 30 days. The interval between the end time and the start time must be within 24 hours.
    Note By default, the slow log trend within the last 15 minutes is displayed.
    Slow log trend
  6. Optional:To view the slow log trend of a specific node, click the ID of the node in the Nodes section.
    Click a node
  7. In the Slow Log Trend section, click a time point in the line chart. Then, you can view the statistics of the slow logs at the point in time on the Slow Log Statistics tab.
    Slow log statistics
  8. To troubleshoot slow SQL queries, use one of the following methods:
    • Click Sample in the Actions column of the slow SQL query to view the details of the slow SQL query. Sample
    • Click Optimize in the Actions column of the slow SQL query to view the diagnostic results and suggestions. Optimization
      Note You can also click Expert Service to purchase the expert service. The expert service provides value-added professional database services, such as emergency solutions, health diagnostics, performance optimization, security assurance, and data migration.

Export slow logs

You can click Export Slow Log to export and save slow logs on your on-premises machines. Export icon

Related API operations

API Description
DescribeSlowLogRecords Queries the details of slow logs for a PolarDB for MySQL cluster.
DescribeDBClusterAuditLogCollector Queries whether SQL data collector is enabled for a PolarDB for MySQL cluster. The features of SQL data collector include audit logs and SQL Explorer.
ModifyDBClusterAuditLogCollector Enables or disables SQL data collector for a PolarDB for MySQL cluster. The features of the SQL data collector include audit logs and SQL Explorer.