Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL when deleting data will free up space

Shulou Source: shulou.com Published: 2022-06-01 05:52:52 10月03日 Update

1. Drop table table_name immediately frees up disk space, whether it's Innodb or MyISAM.

2. Truncate table table_name immediately frees up disk space, whether it's Innodb or MyISAM. Truncate table is actually a bit like drop table and then create. It's just that the create table process has been optimized, such as the table structure file has been available before, and so on, so there is no need to do it again. So the speed should be close to the speed of drop table.

3. For delete from table_name: delete all data in the table

For MyISAM, disk space will be released immediately (it should be a special treatment, and it is reasonable)

InnoDB does not free up disk space

4. For conditional deletion of delete from table_name where xxx, neither innodb nor MyISAM will free disk space.

5. Using optimize table table_name after delete operation will release disk space immediately. Whether it's innodb or myisam. So to achieve the purpose of cleaning up the data, ask delete to perform the optimize table operation later.

6. Although the delete from table does not release disk space in the future, it can still be used the next time the data is inserted.

Tags: Space disk data or speed but file time condition purpose structure process situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia Microsoft Xiaomi OPPO Reno