SOFTELメモ Developer's blog

会社概要 ブログ 調査依頼 採用情報 ...
てるてる動画

【MySQL】Table does not support optimize, doing recreate + analyze instead って何?

MySQLではテーブル最適化はほとんど必要ないので、この件を気にする人もほとんどいないと思います。

偶然 optimize table したら見かけたのでメモ。

optimize table したら何かエラーっぽいものが出たよ?

日本語版のMySQL5.1のマニュアルには見当たらないが、英語版のマニュアルには説明がある。

For InnoDB tables, OPTIMIZE TABLE is mapped to ALTER TABLE, which rebuilds the table to update index statistics and free unused space in the clustered index. Beginning with MySQL 5.1.27, this is displayed in the output of OPTIMIZE TABLE when you run it on an InnoDB table, as shown here:

mysql> OPTIMIZE TABLE foo;
+----------+----------+----------+-------------------------------------------------------------------+
| Table    | Op       | Msg_type | Msg_text                                                          |
+----------+----------+----------+-------------------------------------------------------------------+
| test.foo | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| test.foo | optimize | status   | OK                                                                |
+----------+----------+----------+-------------------------------------------------------------------+

http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html

optimize table は MyISAM、InnoDBのテーブルに使用できる。

optimize table は InnoDBのテーブルに対しては、alter table で対応している。つまり、テーブルを再作成して、インデックスを作り直している。

MySQL 5.1.27以降、「実際のところそういうことなんだよ」というメッセージが表示されるようになった。

optimize table は正常に実行できているので、大丈夫。

関連するメモ

コメント(2)

bb 2011年6月9日 12:20

ナイスです