暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Optimize Table 和 Analyze Table区别

晃荡萝卜DBs 2021-07-26
1336

From official doc:

  • ANALYZE TABLE will update the index statistics for the table.

  • OPTIMIZE TABLE will actually reorganize the data inside the data file.


按表和索引的关系特性,Analyze的代价远远小于Optimize。


通常碎片多的表需要analyze而它需要付出只读的代价,故MySQL引入了以下2个按需求取样的参数来减缓read only的时长:

innodb_stats_transient_sample_pages
 https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_stats_transient_sample_pages  和 innodb_stats_persistent_sample_pages
 https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_stats_persistent_sample_pages



文章转载自晃荡萝卜DBs,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论