All Products
Search
Document Center

ApsaraDB RDS:Use automatic fragment reclamation

Last Updated:Mar 28, 2026

When you delete or update records in a MySQL table, InnoDB cannot always reuse the freed space for new data — the leftover gaps become tablespace fragments. Over time, fragments scatter table data across non-contiguous disk pages, increasing I/O and degrading query performance. Database Autonomy Service (DAS) monitors fragment levels on your ApsaraDB RDS for MySQL instance and automatically runs OPTIMIZE TABLE or ALTER TABLE during the configured maintenance window to reclaim the space.

Prerequisites

Before you begin, ensure that you have:

  • An RDS instance running RDS High-availability Edition, RDS Enterprise Edition, or RDS Cluster Edition

  • An RDS instance that has been running for more than 14 days

  • An RDS instance with at least four CPU cores

  • Physical tables that use the InnoDB engine

How it works

DAS evaluates each table against your configured thresholds, then runs a series of safety checks before executing Automatic Fragment Recycling on the primary instance during its maintenance window.

Threshold evaluation — DAS targets a table when both conditions are met:

  • Table size is between 5 GB and 100 GB (controlled by the Tablespace parameter)

  • Fragment ratio exceeds your configured percentage (controlled by the Fragmentation Percentage parameter)

A table is excluded from reclamation if all tables are smaller than 5 GB or larger than 100 GB, or if the fragment ratio of all tables is below 10%.

Pre-reclamation checks — After a table passes threshold evaluation, DAS runs two categories of checks:

Immediate-stop checks — If either fails, DAS skips the table without retrying:

CheckRequirement
Free disk spaceAt least 3× the physical size of the table. For example, a 30 GB table requires 90 GB of free space.
Table structureNo full-text index (FULLTEXT).

Retry checks — If any of these fails, DAS waits 1–5 minutes and reruns them. If they do not pass within the maintenance window, DAS retries during the next window:

CheckRequirement
Backup jobsNo backup jobs running on the instance
Schema changesNo schema evolution operations in progress
CPU utilizationBelow 70% during the same time slot on the previous day and previous week; below 80% immediately before the operation starts
Long-running queriesNo SQL statement running for more than 3 seconds on the target table
Pending transactionsNo transaction holding a lock for more than 15 seconds
Active sessionsFewer than 64 active sessions on the instance

Example: For a 90 GB table, if reclamation is estimated to take 30 minutes and is scheduled to start at 03:00 on December 10:

  • CPU utilization from 03:00–03:30 on December 9 must be below 70%

  • CPU utilization from 03:00–03:30 on December 3 must be below 70%

  • CPU utilization at 03:00 on December 10 must be below 80%

If checks fail and the maintenance window closes, you can manually reclaim space by running OPTIMIZE TABLE. For instructions, see Use the OPTIMIZE TABLE command to release the tablespace of a MySQL instance.

Activate the DAS O&M service

Automatic Fragment Recycling requires an active DAS Operations and Maintenance (O&M) service. If you have already activated it, skip this section.

  1. Log on to the DAS console.

  2. In the left-side navigation pane, choose Resources > Instances.

  3. On the Instances page, find your RDS instance and click Activate in the O&M Service column.

  4. In the panel that appears, select a Service Duration and click Activate.

Enable and configure automatic fragment reclamation

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

  2. In the left-side navigation pane, choose Autonomy Services > Diagnostics. On the page that appears, click the Autonomy Center tab, then click Autonomy Service Settings.

  3. On the Autonomous Function Settings tab of the Autonomous Function Management panel, enable the autonomy service. On the Optimization and Throttling tab, select Automatic Fragment Recycling.

  4. Configure the thresholds, then click OK.

    Important

    DAS triggers reclamation only when a table meets both thresholds simultaneously, and only during the instance's maintenance window.

    ParameterDescriptionValid valuesDefault
    TablespaceMinimum physical size of a table to be reclaimed. If you set this parameter to a large value, the reclamation process may require a long period of time to complete.5–100 GB10 GB
    Fragmentation PercentageMinimum fragment ratio required to trigger reclamation10%–99%20%

    A lower Tablespace value targets more tables. A lower Fragmentation Percentage value triggers reclamation more frequently. Set both values based on your storage capacity and acceptable performance overhead.

    Example: With Tablespace set to 5 GB and Fragmentation Percentage set to 10%, DAS reclaims all tables with a size between 5 GB and 100 GB and a fragment ratio of 10% or higher.

  5. (Optional) In the Select Alert Template step, configure alert notifications to track reclamation task status. DAS recommends an alert template and adds the required alert rules automatically. Follow the on-screen prompts to complete the configuration.

    Note
    1. In the Select Alert Contact Group step, select a contact group. For more information, see Manage alert contacts.

      • Click Add Contact to add an alert contact.

      • Click Create Contact Group to create a contact group.

      • To modify or remove an existing contact, find it in the list 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 in the dialog box that appears.

What's next

After enabling automatic fragment reclamation, monitor the instance's storage usage and CPU utilization during maintenance windows to verify that reclamation completes successfully. If reclamation is repeatedly skipped due to failing checks, review the specific check conditions — particularly CPU utilization trends and the free disk space available relative to your largest tables.