Row-level locks
Row-level locking doesn't lock SELECT statements at all; they are used to lock UPDATE and DELETE statements. As in table-level locks, no two transactions can lock a row in the conflicting row-level lock mode. Row locking is useful in a scenario where the application inspects the value of the row before updating it. Another scenario is to lock users from updating an old value; for example, if you are editing a document, the application should forbid users from editing it. In PostgreSQL 9.5, the SKIP LOCKED option was introduced, which changes the behavior of row locking. The SKIP LOCKED option is useful in handling batch processing without introducing a high wait time, or handling queues and pools on the database's side.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access