mysql 删除大量数据后 释放空间

delete命令根本不会回收空间,也就是说之前假如这个文件占了100G ,delete后,文件大小没有改变。当全表扫描的时候,还是扫这么多的数据块。当执行完alter table 命令后,它会回收空间。假如删了80G,它的物理文件会只占20G空间。

eg:  alter table table_name engine=innodb;  

--最好隔一段时间 去alter 一下 这个操作锁表。

alter table t_base_access_log engine='InnoDB';
truncate table t_temp_access_uv_log;
alter table t_temp_access_uv_log engine='InnoDB';

猜你喜欢

转载自wangqiaowqo.iteye.com/blog/2086179