~/talk

Understanding Locking and Concurrency in PostgreSQL

Talkat PGConf India 2026 · 2026-03-11..03-13· [databases]
links:none on file
slides:none on file

Explains that PostgreSQL uses three real lock layers with concrete tradeoffs: spin locks held for nanoseconds as the low level primitive, LW locks that allow read/write modes but have no deadlock detection, and heavyweight locks managed by the lock manager and visible via pg_locks shows heavyweight locks. Points out eight table lock modes, row locks stored on disk so no escalation limit, prepared transactions that survive restarts and appear with pid 0, and practical fixes: pg_stat_activity/pg_locks queries, CONCURRENTLY variants, short transactions and idle_in_transaction_timeout.

AI-written summary · about

  1. 0:00Introduction to locking
  2. 1:31Locking subsystems overview
  3. 6:29Spin locks in PostgreSQL
  4. 7:55Lightweight locks explained
  5. 12:53Heavyweight locks deep dive
  6. 19:41Row-level locks and their use
  7. 22:28Lock lifecycle and management
  8. 25:16Prepared transactions and locks
  9. 27:48Lock manager internals
  10. 29:13Deadlock detection and resolution
  11. 31:04Diagnosing lock issues
  12. 33:54Handling blocked transactions
  13. 34:36Dangers of access exclusive locks
  14. 36:43Concurrent DDL operations
  15. 38:30Best practices for locking
  16. 40:13Summary and Q&A
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.