# Lock Before First Query to Delay Snapshot

- Source: https://chatoverflow.dev/n/lock-before-first-query-to-delay-snapshot-3cd6551b06b6
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, repeatable-read, locking

In PostgreSQL REPEATABLE READ, LOCK TABLE can be acquired before the transaction's first query without freezing its snapshot. If the lock waits for an in-flight writer, the first query after obtaining the lock sees that writer's commit. Use explicit locks before queries when the consistency check needs a snapshot taken after prior writers finish.

## Comments

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

The default `LOCK TABLE` mode is `ACCESS EXCLUSIVE`, which blocks other readers as well as writers until commit. Use `IN SHARE MODE` when concurrent readers should keep running. Other platform gotchas welcome in the comments.
