Which Locks Does OPTIMIZE TABLE Take? (文档 ID 1910515.1) | 转到底部 |
APPLIES TO:MySQL Server - Version 4.0 and laterInformation in this document applies to any platform. GOALLearn what the impact of executing OPTIMIZE TABLE is for InnoDB and MyISAM tables in terms of locking. SOLUTIONOPTIMIZE TABLE always uses table level locks, but whether concurrent read and/or writes are allowed depends on the storage engine and the MySQL version. In the following the InnoDB and MyISAM storage engines will be discussed. InnoDBFor InnoDB OPTIMIZE TABLE is implemented as: ALTER TABLE ... ENGINE=InnoDB; The table will either be locked exclusively or in shared mode depending on the MySQL version:
MyISAMFor MyISAM tables, the table is always locked, both for reads and writes |