简体   繁体   中英

Confusion regarding INNODB locking

When i run 'Select * from table' on an INNODB table, does the table get locked implicity? Does it mean that during the time MySQL takes to return the result set, i cannot issue an update statement on the table?

From what i have understood, the whole table would be locked in shared mode until the result set is returned from the server. Only then could the update command be executed.

InnoDB uses a feature called Multi-version concurrency control .

Locking in shared mode is not required, since MVCC will retain earlier versions of the row for your SELECT statement to be able to read if required.

So the answer is 'no', running a SELECT statement will not need to lock any rows while updating. That is, unless it is a special SELECT statement like SELECT .. FOR UPDATE .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM