Optimize InnoDB Table遇到的問題

來源:互聯網
上載者:User

近日在兩個物品記錄表中分別製造了10億的資料(不要問我什麼業務會有這麼多資料^_^),每個表分別有9個欄位,基本是int。之前估算過表的大小,但沒有計算磁碟佔用情況,這次測試主要就是想瞭解下磁碟佔用情況。


/data總容量200GB,10億資料很快就寫滿了,於是又開始刪資料,但發現InnoDB儲存引擎在刪除資料後並不自動釋放磁碟空間。在老葉的部落格上我們學習到可以通過optimize table文法或alter
table TableName engine=innodb來實現空間的釋放。


我的MySQL版本是5.1.38,在optimize執行了很久之後系統提示

Table does not support optimize, doing recreate + analyze instead

……好無語啊,消耗了時間不說,結果還沒有執行成功


在網上搜尋了下看到MySQL管網對optimize文法有詳細的說明,參見http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html

其中關鍵在這裡

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

You can makeOPTIMIZE TABLE work on other storage engines by starting mysqld with the --skip-new or --safe-mode option.
In this case, OPTIMIZE TABLE is just mapped toALTER TABLE.

上面是說要求我們在啟動的時候指定--skip-new或者--safe-mode選項來支援optimize功能


我就是沒有指定這些選項遇到了上面的問題,按照上面的要求重新啟動後就好了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.