MySQL: OPTIMIZE TABLE: Table does not support optimize, doing recreate + analyze instead


show create table history;
--------------------------
CREATE TABLE `foo` (
  `itemid` bigint(20) unsigned NOT NULL,
  `clock` int(11) NOT NULL DEFAULT '0',
  `value` double(16,4) NOT NULL DEFAULT '0.0000',
  `ns` int(11) NOT NULL DEFAULT '0',
  KEY `history_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

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



这里mysql给的提示是
Note>> Table does not support optimize, doing recreate + analyze instead 
Status>> OK
也就是说 optimize table 对于innodb来说,无法作为
a single operation,实际的操作是:
ALTER TABLE test.foo ENGINE=InnoDB;
ANALYZE TABLE test.foo;

   MySQL5.7已经推荐对于InnoDB的table使用 alter table table_name engine=innodb;语句的方式来进行表碎片优化。

 

  底层实现的不同,参考:https://dev.mysql.com/doc/refman/5.7/en/optimize-table.html

 

 

 




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM