查询所有表空间的碎片
select concat('optimize table ', table_schema, '.', table_name, ';'), data_free/1024/1024, engine
from information_schema.tables
where data_free > 0
and engine != 'MEMORY';
查询某一个碎片空间
show table status like 'requestlog';
整理表空间
alter table requestlog engine = innodb,algorithm = inplace ;
这个整理语句不会锁表,但是会造成卡顿
评论区