If I drop an innodb table when will the disk space be reclaimed? Does it happen immediately?
如果我删除一个innodb表什么时候会回收磁盘空间?它会立即发生吗?
How about with records instead of the entire table?
如何使用记录而不是整个表?
1 个解决方案
#1
3
It depends on whether you enabled the innodb_file_per_table
server setting or not.
这取决于您是否启用了innodb_file_per_table服务器设置。
If innodb_file_per_table
is enabled, then each table stores its data in a separate .ibd file. Otherwise the data for all tables is stored in a shared .ibd file.
如果启用innodb_file_per_table,则每个表将其数据存储在单独的.ibd文件中。否则,所有表的数据都存储在共享的.ibd文件中。
With innodb_file_per_table
:
使用innodb_file_per_table:
- When you drop a table the .ibd file is deleted and the disk space is immediately freed.
- 删除表时,将删除.ibd文件,并立即释放磁盘空间。
- When you delete records it frees up space inside the .ibd file, but does not shrink it. Rebuilding the table (such as by running
OPTIMIZE TABLE
) will free up the disk space. - 删除记录时,它会释放.ibd文件中的空间,但不会缩小它。重建表(例如通过运行OPTIMIZE TABLE)将释放磁盘空间。
Without innodb_file_per_table
:
没有innodb_file_per_table:
- Dropping a table or deleting rows from a table frees up space in the shared .ibd file to be used to store future data, but the shared .ibd file will never shrink
- 删除表或从表中删除行会释放共享.ibd文件中的空间以用于存储将来的数据,但共享.ibd文件永远不会缩小
#1
3
It depends on whether you enabled the innodb_file_per_table
server setting or not.
这取决于您是否启用了innodb_file_per_table服务器设置。
If innodb_file_per_table
is enabled, then each table stores its data in a separate .ibd file. Otherwise the data for all tables is stored in a shared .ibd file.
如果启用innodb_file_per_table,则每个表将其数据存储在单独的.ibd文件中。否则,所有表的数据都存储在共享的.ibd文件中。
With innodb_file_per_table
:
使用innodb_file_per_table:
- When you drop a table the .ibd file is deleted and the disk space is immediately freed.
- 删除表时,将删除.ibd文件,并立即释放磁盘空间。
- When you delete records it frees up space inside the .ibd file, but does not shrink it. Rebuilding the table (such as by running
OPTIMIZE TABLE
) will free up the disk space. - 删除记录时,它会释放.ibd文件中的空间,但不会缩小它。重建表(例如通过运行OPTIMIZE TABLE)将释放磁盘空间。
Without innodb_file_per_table
:
没有innodb_file_per_table:
- Dropping a table or deleting rows from a table frees up space in the shared .ibd file to be used to store future data, but the shared .ibd file will never shrink
- 删除表或从表中删除行会释放共享.ibd文件中的空间以用于存储将来的数据,但共享.ibd文件永远不会缩小