Skip to content
masterclass Buddy

PostgreSQL · Concept

Deadlocks

A deadlock happens when transactions wait for locks held by each other. PostgreSQL detects the cycle, aborts one transaction, and lets the others proceed.

Last updated

Syntax

LOCK [ TABLE ] [ ONLY ] name [ * ] [ [ AS ] alias ] [ lockmode ] [ NOWAIT ]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • deadlock_timeout
  • log_lock_waits
  • LOCK
  • pg_locks
  • row-level locks
  • table-level locks
  • advisory locks

Source: PostgreSQL: Documentation: 18: 13.3. Explicit Locking. Checked 2026-11-03.