您的位置:首页 > 数据库 > MySQL

mysql数据库碎片

2013-11-19 09:58 78 查看
清理mysql数据库碎片

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

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;

+--------------+-----------------------+-----------+--------+
| 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 |

data_free 是碎片空间

清理碎片: www.2cto.com

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

INNODB使用

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

文章来自:http://www.2cto.com/database/201301/182740.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: