PrepZone Logo
PrepZone
Back to Database

Database · Medium

What does SELECT ... FOR UPDATE do? Explain SKIP LOCKED and NOWAIT.

DatabaseTransactionsSenior

Answer preview

SELECT ... FOR UPDATE takes a row-level exclusive lock on every row the query returns, held until the transaction ends. It turns a read into the first half of a safe read-modify-write — this is pessimistic locking.…