MySQL碎片整理InnoDB表

时间:2014-10-22 18:02:38

标签: mysql query-optimization innodb mysqltuner

运行mysqltuner后,我收到了这个输出:

Total fragmented tables: 284

要进行碎片整理,我尝试了这些:

1. ALTER TABLE tbl_name ENGINE=INNODB
2. Another way to perform a defragmentation operation is to use mysqldump to dump the table to a text file, drop the table, and reload it from the dump file.

MySQL documentation中描述了这两种方法。

但这些方法都没有帮助。 Mysqltuner仍然说表格是碎片化的。

注意: innodb_file_per_table在我的配置中处于关闭状态。

如何对InnoDB表进行碎片整理?

3 个答案:

答案 0 :(得分:0)

ALTER TABLE tbl_name ENGINE = INNODB

是对innodb表进行碎片整理的唯一方法。

ALGORITHM = INPLACE可以帮助我们在线完成。

答案 1 :(得分:0)

  

从MySQL 5.5.11开始,您还可以使用 ALTER TABLE tbl_name FORCE   执行重建表的“null”更改操作。   以前FORCE选项被识别但被忽略。

https://dev.mysql.com/doc/refman/5.5/en/alter-table.html

答案 2 :(得分:0)

我遇到了同样的问题,并且对我有用的解决方案是在analyze之后进行alter

alter table xyz engine=InnoDB;
analyze table xyz;
相关问题