mysqls清碎片


说明: mysql

每当MySQL从你的列表中删除了一行内容,该段空间就会被留空。而在一段时间内的大量删除操做,会使这种留空的空间变得比存储列表内容所使用的空间更大。当MySQL对数据进行扫描时,它扫描的对象实际是列表的容量需求上限,也就是数据被写入的区域中处于峰值位置的部分。若是进行新的插入操做,MySQL将尝试利用这些留空的区域,但仍然没法将其完全占用。 sql


mysql> select table_schema, table_name, data_free, engine     from information_schema.tables where table_schema not in ('information_schema', 'mysql') and data_free > 0; app

+--------------+-----------------------+-----------+--------+
| table_schema | table_name            | data_free | engine |
+--------------+-----------------------+-----------+--------+
| BK           | comments              |   9437184 | InnoDB |
| BK           | historypwd            |   9437184 | InnoDB |
| ss | app_admin_log         |        434 | MyISAM |
| ss | app_article           |        4434 | MyISAM |
|ss | app_article_category  |        43420 | MyISAM |
| ss | app_config            |        3324 | MyISAM |
| ss | app_convert_key       |       1132 | MyISAM | spa


data_free 是碎片空间 orm

清理碎片: 对象

optimize table ss.app_article;                      该方式只支持MyIsam引擎 io


INNODB使用 table

ALTER TABLE table.name ENGINE='InnoDB';             使用前最好备份 form

相关文章
相关标签/搜索