且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL InnoDB锁定联接的行

更新时间:2023-02-07 18:27:05

请参见此MySQL文档页面.它说:

锁定读取,UPDATE或DELETE通常会对在处理SQL语句时扫描的每个索引记录设置记录锁定.语句中是否存在排除行的条件并不重要.

A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of the SQL statement. It does not matter whether there are WHERE conditions in the statement that would exclude the row.

和:

对于SELECT ... FOR UPDATE或SELECT ...共享模式锁定,将为扫描的行获取锁定,并预期将其释放给不符合包含在结果集中的行(例如,如果它们被锁定)不符合WHERE子句中给出的条件).但是,在某些情况下,行可能不会立即被解锁,因为结果行与其原始源之间的关系在查询执行期间会丢失.

For SELECT ... FOR UPDATE or SELECT ... LOCK IN SHARE MODE, locks are acquired for scanned rows, and expected to be released for rows that do not qualify for inclusion in the result set (for example, if they do not meet the criteria given in the WHERE clause). However, in some cases, rows might not be unlocked immediately because the relationship between a result row and its original source is lost during query execution.

扫描的行"是指联接中使用的任何表中的行.

"scanned rows" refers to rows from any of the tables that are used in the join.