mysql OPTIMIZE TABLE 对数据库的影响

Which Locks Does OPTIMIZE TABLE Take? (文档 ID 1910515.1)转到底部转到底部

 

APPLIES TO:

MySQL Server - Version 4.0 and later
Information in this document applies to any platform.

GOAL

Learn what the impact of executing OPTIMIZE TABLE is for InnoDB and MyISAM tables in terms of locking.
 

SOLUTION

OPTIMIZE 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.

InnoDB

For InnoDB OPTIMIZE TABLE is implemented as:

ALTER TABLE ... ENGINE=InnoDB;
ANALYZE TABLE ...;

The table will either be locked exclusively or in shared mode depending on the MySQL version:

  • MySQL 5.5 and earlier: Concurrent reads are possible, but writes are blocked.
  • MySQL 5.6.16 and earlier: Concurrent reads are possible, but writes are blocked.
  • MySQL 5.6.17 and later: Concurrent reads and writes are possible.
mysq 版本并发读并发写 
MySQL 5.5 and earlier:YESNO 
MySQL 5.6.16 and earlier:possibleblocked 
MySQL 5.6.17 and later:YESYES 
Notes:

 

MyISAM

For MyISAM tables, the table is always locked, both for reads and writes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值