Question :
Does Postgresql apply the same type of locks on UPDATE
with a range condition and on UPDATE
with in-set condition?
E.g. will the queries:
UPDATE table WHERE id IN (1,2,3,4,5,6,7,8,9,10);
UPDATE table WHERE id >= 1 AND id < 11
;
Cause the same type of locks on table
?
Answer :
Yes, both statements will take a UPDATE
lock on all the modified rows.
See the documentation on row locks:
The
FOR UPDATE
lock mode is also acquired by anyDELETE
on a row, and also by anUPDATE
that modifies the values on certain columns.