All Products
Search
Document Center

:Release the tablespaces of MySQL instances

Last Updated:Jun 14, 2023

Overview

This topic describes how to release a tablespace of an ApsaraDB RDS for MySQL instance.

Background information

Note

Alibaba Cloud reminds you that:

  • When you perform operations that have risks, such as modifying instance configurations or data, check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.

  • Before you modify the configurations and data of instances including but not limited to ECS and RDS instances, we recommend that you create snapshots or enable RDS log backup.

  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

You can execute the OPTIMIZE TABLE statement to release a tablespace of your RDS instance and reorganize the physical pages of table data and indexes. This reduces the occupied disk space and optimizes read/write performance. If you execute the DELETE statement to delete a database from your RDS instance, the tablespace that stores the tables of the database is not directly released. You must execute the OPTIMIZE TABLE statement to release the tablespace.

Precautions

  • When you release a tablespace of your RDS instance, the tables in the tablespace are locked. We recommend that you perform this operation during off-peak hours.

  • You can execute the OPTIMIZE TABLE statement only when your RDS instance runs the InnoDB or MyISAM storage engine.

Use the CLI to release a tablespace

  1. Use a database client to connect to your ApsaraDB RDS for MySQL instance. This topic uses MySQL-Front as an example.

  2. Click the SQL editor tab.

  3. Execute the following SQL statement to release the specified tablespace:

    optimize table [$Database1].[ Table1],[$Database2].[ Table2]
    Note

    Note:[$Database1] and [$Database2] are database names, and [Table1] and [Table2] are table names.

Use Data Management (DMS) to release a tablespace

  1. Log on to your ApsaraDB RDS for MySQL instance by using DMS.

  2. In the left-side navigation pane, right-click a database and choose Batch operation table.

  3. On the Batch operation table tab, select the tables whose tablespace you want to release. Then, click Table Maintenance and select Optimize Table.

  4. In the message that appears, click Yes.

Application scope

  • ApsaraDB RDS for MySQL