以下論述均假定innodb_file_per_table開啟
先用常規optimize回收
[plain]
<pre name=
+
| count(*) |
+
|
+
[mysql@even employees]$ ls
mysql> delete from t limit
mysql> select count(*) from t;
+
| count(*) |
+
|
+
[mysql@even employees]$ ls
mysql> optimize table t;
+
| Table | Op | Msg_type | Msg_text |
+
| employees
| employees
+
[mysql@even employees]$ ls
來看下這種方法的缺陷
[plain]
mysql> show processlist;
+
| Id | User | Host | db | Command | Time | State | Info |
+
|
|
+
mysqladmin debug結果如下
[plain]
Thread database
用optimize缺點顯而易見
這裡推薦使用percona公司
[plain]
$ pt
執行pt工具時有可能發生的類似錯誤
[plain]
Cannot chunk the original table There is no good index and the table is oversized
這是因為被作用的表需要含有主鍵或者唯一索引
From:http://tw.wingwit.com/Article/program/MySQL/201311/29468.html