gap lock
A lock on a gap between index records, or a lock on the gap before the first or after the last index record. For example, SELECT c1 FOR UPDATE FROM t WHERE c1 BETWEEN 10 and 20;
prevents other transactions from inserting a value of 15 into the column t.c1
, whether or not there was already any such value in the column, because the gaps between all existing values in the range are locked. Contrast with record lock and next-key lock.
Gap locks are part of the tradeoff between performance and concurrency, and are used in some transaction isolation levels and not others.
See also gap.
See also infimum record.
See also lock.
See also next-key lock.
See also record lock.
See also supremum record.