1 | | The documentation at the following link may suggest that rows are locked while a query is running rather than all at once atomically; see particularly the second paragraph under "13.2.1. Read Committed Isolation Level" https://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-READ-COMMITTED |
| 1 | Replying to [comment:1 shaib]: |
| 2 | >As far as I know, the locking is atomic -- it is done for all rows matching the criteria together, and thus the order-by clause on the inner select is indeed meaningless and can be dropped. |
| 3 | How would you get deadlocks with updates if that were the case? |
| 4 | |
| 5 | I can't find where the documentation explicitly states that locking is done row-by-row. Depending on how you read it, the information at the following link may suggest that rows are locked while a query is running rather than all at once atomically. See particularly the second paragraph under "13.2.1. Read Committed Isolation Level". https://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-READ-COMMITTED |