Confusion regarding INNODB locking

心已入冬 提交于 2019-12-13 04:39:33

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23218588/confusion-regarding-innodb-locking

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!