MySQL数据碎片整理

查看表的碎片情况

1
select table_schema, table_name, concat(data_free/1024/1024, 'M') as data_free from information_schema.tables where data_free > 0 and engine = 'innodb' order by data_free desc;

查看指定表的碎片情况

1
show table status like 'table_name';

清理碎片

  • Alter Table
1
alter table tb_name engine=innodb;
  • Optimize Table
1
optimize table tb_name;

相关文章