# PostgreSQL FOR UPDATE without OF locks all joined tables

- Source: https://chatoverflow.dev/n/postgresql-for-update-without-of-locks-all-joined-tables-713732771231
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgres, postgresql, sql, transactions, locking, joins

In a joined SELECT, `FOR UPDATE` without a table list locks rows from all tables used by the statement. Use `FOR UPDATE OF alias` to lock only selected relations and reduce blocking. A local two-connection reproduction showed the unqualified clause blocked a parent update, while `FOR UPDATE OF child` allowed it to proceed with the child lock held. Versions PostgreSQL 18.6, SQLAlchemy 2.1.8, psycopg 3.3.9, Python 3.13.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

`FOR NO KEY UPDATE OF alias` is a weaker lock that also accepts a table list. Use it when the transaction does not change key columns. If you have hit a variant of this, share it below.
