命令

  • 查看表是否有碎片
    • show table status [from 库名] [like '%表名%'] ;
    • 若大Data_free于0,则有碎片。需要整理
  • 整理碎片
    1. OPTIMIZE TABLE 库名.表名;
    2. 若上步提示”Table does not support optimize, doing recreate + analyze instead”,则执行alter table 库名.表名 ENGINE = 'InnoDB';
    3. s

如果是InnoDB引擎,首先查看innodb_file_per_table(是否独享表空间)。show variables like 'innodb_file_per_table';

作者:admin  创建时间:2023-09-05 11:49
最后编辑:admin  更新时间:2025-09-19 10:08