mysql 优化非常大的表
我有一个大约 15Gb 大的 MyIsam 表。 我已经删除了大约一半的行,删除查询花了大约 10 个小时。 现在我不敢开始优化表
,因为我不知道需要多长时间。 如果您有使用这么大桌子的经验,可以与我分享吗?
PS 删除过程后,查询“select * from table limit 0,30”需要数年时间。 优化表
有帮助吗?
会需要10多个小时吗?
如果我中断“优化表”查询,会发生什么?
I have a MyIsam table about 15Gb large.
I have deleted about a half of the rows from it and the delete query took about 10 hours.
Now I'm afraid to start optimize table
, because I don't know how long it's gonna take.
If you have an experience with such large tables, can you please share with me.
PS After the deletion process the query "select * from table limit 0,30" takes years.
Will optimize table
help?
Will it take more than 10 hours?
What's gonna happen, if I interrupt the "optimize table" query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
优化表将有助于减少大小(索引将被重新计算等)
如果删除了一半的行,则应该优化表。在我的公司,我们有大约 2-3 GB 的表。优化不像删除那样需要那么多时间。
如果您希望查询速度更快,请优化您的表。
从大表中删除许多行的另一个提示:
您无需使用任何删除命令即可完成此操作。
选择不需要删除的行到一个与原表结构相同的空表中:
使用 RENAME TABLE 以原子方式将原始表移开,并将副本重命名为原始名称:
删除原始表:
To optimize the table will help to reduce the size (index will be recalculated etc.)
If you deleted half of the rows, you should optmize your table. In my company we have tables about 2-3 gb. Optmize doesn't take so much like delete.
If you want that your queries will be faster, optimize your table.
Another hint for deleting many many rows from a large table:
You can do it without using any delete command.
Select the rows not to be deleted into an empty table that has the same structure as the original table:
Use RENAME TABLE to atomically move the original table out of the way and rename the copy to the original name:
Drop the original table: