操作系统 
首页 > 操作系统 > 浏览文章

optimize table出错解决方法

(编辑:jimmy 日期: 2024/10/3 浏览:3 次 )
一个某某库大概360W,为了提高查询效率,做点优化,使用optimize table table.name;出现Table does not support optimize, doing recreate + analyze instead
果断谷歌,查到一段E文。。。

Everytime you do optimize MySQL, by using mysqlcheck -A -o or using ./mysql_optimize from here.
You may see the output

Table does not support optimize, doing recreate + analyze instead.

It is because the table that you are using is InnoDB.

You can optimize the InnoDB tables by using this.

复制代码代码如下:
ALTER TABLE table.name ENGINE='InnoDB';

This will create a copy of the original table, and drop the original table, and replace to the original place.

Although this is safe, but I suggest you do backup and test first before doing this.

原来如此,大致意思是说innodb的数据库不支持optimize,可以用
ALTER TABLE table.name ENGINE='InnoDB';
该方法会对旧表以复制的方式新建一个新表,然后删除旧表。虽然这个过程是安全的,但是在进行操作时还是先进行备份为好

还有一种方式:

You can make OPTIMIZE 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功能
上一篇:centos中wget的使用方法
下一篇:在CentOS 6.3中安装与配置Tomcat-7方法
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。