Database Autonomy Service (DAS) provides the automatic fragment reclamation feature for ApsaraDB RDS for MySQL. After you enable the feature for your ApsaraDB RDS for MySQL instance, the primary RDS instance automatically executes the OPTIMIZE TABLE or ALTER TABLE statement to reclaim tablespace fragments.
- Your RDS instance runs one of the following database engines and RDS editions and is created 14 days ago:
- MySQL 8.0 on RDS High-availability Edition or RDS Enterprise Edition
- MySQL 5.7 on RDS High-availability Edition or RDS Enterprise Edition
- MySQL 5.6 on RDS High-availability Edition
- Your RDS instance has at least four CPU cores.
- The physical tables on your RDS instance use the InnoDB engine.
- DAS Professional Edition is enabled for your RDS instance. For more information, see Purchase DAS Professional Edition.
- Records are deleted, and the original tablespace cannot be reused.
- Records are updated, and the original tablespace cannot be reused. In most cases, records are updated for variable-length fields.
- Inserted records cause page splits and decrease the fill rate of pages.
Items that the system checks before it recycles tablespace fragments
To mitigate the negative impacts of tablespace fragment recycling on database performance and tablespace, the system checks the database instance and the tables in the instance.
- If one or more of the following requirements are not met, tablespace fragment recycling cannot be performed on the corresponding table.
- The available storage space of the database instance must be at least three times larger than the physical space of the table whose tablespace fragments you want to recycle. Note For example, if you want to recycle the tablespace fragments of the Table_1 table whose physical space is 30 GB, the available storage space of the database instance must be greater than or equal to 90 GB when tablespace fragment recycling is triggered.
- No full-text indexes are created for the table.
- The available storage space of the database instance must be at least three times larger than the physical space of the table whose tablespace fragments you want to recycle.
- If one or more of the following requirements are not met, the system waits for approximately 1 to 5 minutes and then performs the checks again. This process is repeated until the maintenance window ends.
- No backup tasks are being performed on the database instance.
- No schema change tasks are being performed.
- The CPU utilization during the same period of time on the previous day and the CPU utilization during the same period of time on the day that is seven days earlier than the current date must be less than 70%, and the CPU utilization before the recycling task is scheduled to start must be less than 80%. Note For example, tablespace fragment recycling is scheduled to start at 03:00 on December 10 for a table whose physical space is 90 GB, and the operation is expected to take 30 minutes to complete. In this case, make sure that the following requirements are met:
- The CPU utilization must be less than 70% from 03:00 to 03:30 on December 9, 2020.
- The CPU utilization must be less than 70% from 03:00 to 03:30 on December 3, 2020.
- The CPU utilization must be less than 80% from 03:00 on December 9, 2020 to the time when the recycling starts.
- Before the system recycles the tablespace fragments of a table, the system checks the table. If one or more of the following requirements are not met, the system does not start the recycling task:
- No SQL statements take longer than 3 seconds to execute.
- No pending transactions exist. Pending transactions are the transactions that hold locks but are not committed within 15 seconds.
- The number of active sessions on the table is less than 64.
- Access RDS Instances, select a region at the top, and then click the ID of the target RDS instance.
- Go to the Autonomous Function Management panel.
- In the left-side navigation pane, choose Autonomy Center tab. On the Autonomy Center tab, click Autonomy Service Settings. . On the page that appears, click the
- In the left-side navigation pane, choose Performance Trends tab of the page that appears, click Autonomy Service Settings. . On the
- On the Autonomous Function Settings tab, enable the autonomy service. On the Optimization and Throttling tab, select Automatic Fragment Recycling.
- Configure the following parameters and click OK. Important When the storage usage of a table on the RDS instance reaches the specified thresholds, DAS automatically reclaims the tablespace fragments during the specified maintenance window for the RDS instance.
Parameter Description Tablespace >
The threshold of storage usage for a physical table. Unit: GB. Valid values: 5 to 100. Default value: 10.
If you set this parameter to a large value, the reclamation process may take a long period of time to complete. We recommend that you specify a value based on your business requirements.Note If the storage usage of all tables on the RDS instance is less than 5 GB or greater than 100 GB, DAS does not reclaim the tablespace fragments.
Fragmentation Percentage >
The percentage of the storage usage of tablespace fragments to the total storage usage of a physical table. Valid values: 10 to 99. Default value: 20.
If you set this parameter to a large value, automatic fragment reclamation is performed less frequently. We recommend that you specify a value based on your business requirements.Note If the fragmentation rate of all tables on the RDS instance is less than 10%, DAS does not reclaim the tablespace fragments.Note For example, if the value of the Tablespace > parameter is 5 GB and the value of the Fragmentation Rate > parameter is 10%, automatic fragment reclamation is triggered for all tables whose tablespace ranges from 5 GB to 100 GB and whose fragmentation rate is greater than or equal to 10%.