且构网

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

使InnoDB仅锁定当前正在更新的行?

更新时间:2023-02-07 18:30:49

该锁将为整个事务持有(因为该操作是原子的,这意味着所有行都已更新或没有行),并且您可以t更改(不更改存储引擎).但是,它不会阻止读取(除非您处于SEIALIZABLE隔离级别),因此将执行SELECT查询,但它们将读取旧值.更新只会阻止SELECT FOR UPDATE和SELECT ... LOCK IN SHARE MODE.

The lock is held for the entire transaction (as the operation is atomic, this means that either all of the rows are updated or no rows) and you can't change that (without changing the storage engine). However it does not block reads (unless you are in SEIALIZABLE isolation level), so SELECT queries will be executed, but they will read the old values. Only SELECT FOR UPDATE and SELECT...LOCK IN SHARE MODE will be blocked by an update.