As you already know, UPDATE and SELECT … FOR UPDATE lock a row until the end of the transaction. But there are four row lock modes, and these two statements take different ones. In the "SQL Core" course we said they take "the same lock": that is a simplification, since a second change of the same row waits in both cases. Let's go through all four and see where PostgreSQL keeps them.
In this lesson
- Four modes
- Where a row lock is kept
- Whom the waiter waits for
- Common mistake
- Key points