ANALYZE TABLE 和 OPTIMIZE TABLE 有什么区别?

发布时间 2023-05-06 15:47:27作者: 艾森豪威迩

含义区分:ANALYZE TABLE
https://dev.mysql.com/doc/refman/5.7/en/analyze-table.html
ANALYZE TABLE performs a key distribution analysis and stores the distribution for the named table or tables.
执行键分布分析,并存储指名表的分布。更新表的索引统计信息

 

含义区分:OPTIMIZE TABLE
https://dev.mysql.com/doc/refman/5.7/en/optimize-table.html
OPTIMIZE TABLE reorganizes the physical storage of table data and associated index data, to reduce storage space and improve I/O efficiency when accessing the table.
重新组织表数据和相关索引数据的物理存储,以减少访问表时的存储空间并提高I/O效率。会重新组织数据文件中的数据