Resolve cluster storage exhaustion caused by too many data files

Updated at:

This topic describes the symptoms, solution, and routine maintenance for storage exhaustion caused by too many data files.

Symptoms

PolarDB for MySQL clusters can occupy excessive storage space when data files have not been organized for a long time. You can confirm that data space usage is high on the Storage Analysis page of the cluster, in the Storage Trend section, as shown in the following figure:

Data space usage in the Storage Trend section

Solution

Delete redundant data by performing the following steps:

Note
  • Back up your data before you delete a table to prevent data loss.

  • DELETE does not release storage space. Use the DROP or TRUNCATE command to release storage space.

  • OPTIMIZE locks the table. Run this operation during off-peak hours.

  • There is a delay before data file cleanup takes effect. Wait until the used storage space of the cluster decreases.

  • If the following steps still do not release enough storage space by cleaning up data files, you can clean up other types of files to reduce storage usage. For details, see Resolving full cluster storage caused by excessive log files.

  1. Connect to a cluster.

  2. On the SQL Console page, run the following command to view the file sizes of the database and identify the historical or unnecessary data that can be deleted:

    SELECT file_name, concat(TOTAL_EXTENTS,'M') as 'FIle_size' FROM INFORMATION_SCHEMA.FILES order by TOTAL_EXTENTS DESC
  3. Use the DROP or TRUNCATE command to delete data. Replace the database name and the table name in the command line with the actual values.

    DROP TABLE <database name>.<table name>
    TRUNCATE TABLE <database name>.<table name>

Routine maintenance