When you delete or update data in a database table, data storage on disk can become non-contiguous. This fragmentation wastes disk space and degrades performance. Database Autonomy Service (DAS) supports the automatic fragment reclamation feature. During an instance's maintenance window, DAS automatically runs the Optimize Table or Alter Table command on the primary instance to reclaim tablespace fragments and optimize storage.
Prerequisites
The instance is of the RDS High-availability Edition, RDS Enterprise Edition, or RDS Cluster Edition.
The instance is at least 14 days old.
The instance has at least 4 CPU cores.
The physical tables must use the InnoDB engine.
Background information
Common causes of tablespace fragmentation:
Rows are deleted, and the original space cannot be reused.
Updating rows, especially in variable-length fields, can leave space that cannot be reused.
Row insertions cause page splitting, which reduces the page fill factor.
Pre-optimization checks
DAS runs the OPTIMIZE TABLE or ALTER TABLE command on the primary instance to reclaim space from fragmented tablespaces. Before starting an Automatic Fragment Recycling operation, DAS performs the following checks. The Automatic Fragment Recycling operation proceeds only after all checks pass.
-
If any of the following checks fails, DAS immediately stops the Automatic Fragment Recycling operation for that table.
-
The available space on the instance is at least three times the physical space occupied by the target table.
NoteFor example, if the target table occupies 30 GB of physical space, the instance requires at least 90 GB of available space.
-
The table does not have a FULLTEXT index.
-
-
If any of the following checks fails, DAS waits 1 to 5 minutes and retries. If the checks do not pass within the current maintenance window, DAS retries during the next maintenance window. The Automatic Fragment Recycling operation starts only after all checks pass.
-
No backup tasks are running on the instance.
-
No schema change operations are in progress.
-
The instance CPU utilization is below specific thresholds. DAS estimates the time required for Automatic Fragment Recycling and verifies that the CPU utilization during the same time period on the previous day and in the previous week was below 70%. It also verifies that the CPU utilization immediately before the operation is below 80%.
NoteFor example, a table that occupies 90 GB of physical space is scheduled for reclamation at 03:00 on December 10, and the operation is expected to take 30 minutes. DAS verifies the following:
-
The CPU utilization from 03:00 to 03:30 on December 9 was below 70%.
-
The CPU utilization from 03:00 to 03:30 on December 3 was below 70%.
-
The CPU utilization at 03:00 on December 10 is below 80%.
-
-
No queries that have run for more than 3 seconds are executing on the target table.
-
No pending transaction (a transaction that has held a lock for more than 15 seconds without being committed) exists.
-
The number of active sessions on the instance is less than 64.
-
If the checks do not pass, the Automatic Fragment Recycling task does not run. You can manually run the OPTIMIZE TABLE command to reclaim space from fragmented tablespaces. For more information, see Use the OPTIMIZE TABLE command to release the tablespace of a MySQL instance.
Enable the DAS O&M service
Before you use the Automatic Fragment Recycling feature, you must enable the Operations and Maintenance (O&M) service of DAS for the target instance. If the service is already enabled, skip this section.
Log on to the DAS console.
In the navigation pane on the left, click .
On the Instances page, find the target instance and click Activate in the O&M Service column.
In the panel that appears, select a Duration and click Activate to enable the O&M service of DAS for the instance.
Configure automatic fragment reclamation
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
In the navigation pane on the left, choose . On the Autonomy Center page, click Autonomy Service Settings.
On the tab, turn on the switch for autonomous features. Then, on the Optimization and Throttling tab, select Automatic Fragment Recycling.
After you enable Automatic Fragment Recycling, configure the following parameters and click OK.
ImportantWhen the space status of the database instance reaches the specified thresholds, DAS performs automatic fragment reclamation during the instance's O&M Window.
Parameter
Description
Tablespace >
The minimum size of a single physical table that triggers automatic fragment reclamation. Valid values: 5 GB to 100 GB. Default value: 10 GB.
A large table size may prolong the reclamation process. Select a value based on your business requirements.
NoteIf all tables on the instance are smaller than 5 GB or larger than 100 GB, the system does not perform fragment reclamation.
Fragmentation Percentage >
The minimum fragment ratio of a single physical table that triggers automatic fragment reclamation. Valid values: 10% to 99%. Default value: 20%.
A high fragment ratio reduces the frequency of space optimization. Select a value based on your business requirements.
NoteIf the fragment ratio of all tables on the instance is lower than 10%, the system does not perform fragment reclamation.
NoteFor example, if you set Tablespace > to 5 GB and Tablespace > to 10%, automatic fragment reclamation is triggered for all tables between 5 GB and 100 GB in size with a fragment ratio of 10% or higher.
(Optional) Configure an Alert Templates to receive alerts and monitor the Automatic Fragment Recycling status on your instance.
The system recommends an alert template and adds alert rules for the corresponding autonomy events. You can follow the prompts to complete the configuration.
NoteIf you have already configured an alert template for the instance, follow the prompts to add the alert rules for the corresponding autonomy events to the template.
If you want to configure an alert template and alert rules manually, see Configure alert templates and Configure alert rules.
Select an Alert Contact Groups for alert notifications.
Click Add Contact to add a new alert contact.
Click Add Contact Group to add a new contact group.
Click Modify or Remove next to a contact to modify or delete the contact's information.
For more information, see Manage alert contacts.
Confirm the Associate Resources.
Click Submit Configuration and confirm the alert configuration in the dialog box that appears.