Reclaim disk space#
You can configure InnoDB to release disk space back to the operating system by running the
OPTIMIZE TABLE command.
Note that under certain conditions (e.g. including the presence of a
FULLTEXT index), the command
OPTIMIZE TABLE will copy the data to a new table containing just the current data, and then drop and rename the new table to match the old one. During this process, data modification will be blocked. This will require enough free space to store two copies of the current data at once.
To ensure that the space is also reclaimed on standby nodes, run the command as below without any additional modifiers like
``OPTIMIZE TABLE defaultdb.mytable;``
If you do not have enough free space to run the
OPTIMIZE TABLE command, then you can:
Start by optimizing smaller tables to free up space. After, you can proceed with optimizing on larger tables.
Temporarily upgrade to a larger service plan to get access to more disk space. You can downgrade your plan again afterward. Read more on how to upgrade your plan for that.
When you perform a temporary upgrade, it may require waiting for a smaller backup to be taken place before downgrading the plan again.