有关INNODB锁定的困惑 [英] Confusion regarding INNODB locking

查看:85
本文介绍了有关INNODB锁定的困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在INNODB表上运行从表中选择*"时,该表是否隐式锁定?这是否意味着在MySQL需要花时间返回结果集的过程中,我无法在表上发出更新语句?

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使用称为多版本的功能并发控制.

InnoDB uses a feature called Multi-version concurrency control.

不需要锁定共享模式,因为MVCC将保留该行的早期版本,以便您的SELECT语句能够在需要时读取.

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.

因此答案是否",运行SELECT语句将不需要在更新时锁定任何行.也就是说,除非它是特殊的SELECT语句,例如SELECT .. FOR UPDATE.

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.

这篇关于有关INNODB锁定的困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆