All Products
Search
Document Center

ApsaraDB RDS:Use the automatic SQL optimization feature

Last Updated:Mar 28, 2026

Database Autonomy Service (DAS) automatically diagnoses slow SQL queries and manages indexes for ApsaraDB RDS for PostgreSQL instances to maintain optimal performance. With automatic SQL optimization, DAS can:

  • Run daily diagnostics on SQL statements and identify slow queries

  • Recommend indexes to address performance bottlenecks

  • Automatically create or delete indexes based on recommendations (if enabled)

Prerequisites

Before you begin, ensure that you have:

SQL Explorer and Audit allows DAS to distinguish slow SQL from normal SQL queries. Without it, automatic SQL optimization may also optimize normal queries and degrade overall instance performance.

Enable automatic SQL optimization

  1. Go to the Instances page. In the top navigation bar, select the region where the instance resides, then click the instance ID.

  2. Open the Autonomous Function Management panel using one of the following methods:

    • In the left-side navigation pane, choose Autonomy Services > Diagnostics. On the page that appears, click the Autonomy Center tab. In the upper-right corner, click Autonomy Service Settings.

    • In the left-side navigation pane, choose Autonomy Services > Dashboard. On the Performance Trends tab, click Autonomy Service Settings.

  3. On the Autonomous Function Settings tab, turn on the autonomy service switch. On the Optimization and Throttling tab, select Automatic Index Creation and Deletion and choose a mode.

    When automatic index creation is enabled, DAS creates indexes within the maintenance window configured for the instance.
    ModeWhat DAS does
    SQL Diagnostics OnlyRuns daily SQL diagnostics and provides index recommendations. Does not create indexes on the instance.
    SQL Diagnostics and Automatic Index CreationRuns daily SQL diagnostics, provides index recommendations, and automatically creates indexes on the instance.

    Autonomous Function Management

  4. Click OK.

  5. (Optional) In the Alert Configuration section, configure an alert template and subscribe to alert notifications to track the status of automatic SQL optimization tasks. The system recommends an alert template and automatically adds alert rules for the required autonomy events. Follow the on-screen prompts to complete the configuration.

    - If an alert template is already configured for the instance, add alert rules for the required autonomy events to the existing template as prompted. - To configure a new alert template, see Configure alert templates and Configure alert rules.
    1. In the Select Alert Contact Group step, select an alert contact group. For more information, see Manage alert contacts.

      • Click Add Contact to add an alert contact.

      • Click Create Contact Group to create an alert contact group.

      • To modify or delete an existing contact, find the contact and click Edit or Remove in the Actions column.

    2. In the Associate with Resources step, confirm the associated resources.

    3. Click Submit Configuration and confirm the configuration in the dialog box.

What's next

After enabling automatic SQL optimization, view optimization events in the Autonomy Center:

  1. Select a time range to list optimization events.

  2. Find the event and click Details in the Actions column.

  3. On the Root Cause Analysis and Suggestions tab of the Slow SQL Statements Diagnostics (Diagnostics and Optimization) event, review the following sections:

    • Problematic SQL Statements — slow queries identified by DAS

    • SQL Statement Optimization — suggested rewrites or execution plan changes

    • Index Recommendation — indexes DAS recommends creating

    • Statement Optimization — further statement-level improvements

Optimization event details