log_lock_waits
Read PG 18 manual ↗Controls whether a log message is produced when a session waits longer than deadlock_timeout to acquire a lock.
- Type
- bool
- Context
- superuser
- Measured default
- off
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
Controls whether a log message is produced when a session waits longer than deadlock_timeout to acquire a lock. This is useful in determining if lock waits are causing poor performance. The default is off. Only superusers and users with the appropriate SET privilege can change this setting.
Measured default history
| Version interval | Default |
|---|---|
| 9.0 – 18 | off |
| 19 – 19 | on |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
log_lock_waits logs long lock waits. A wait is logged after deadlock_timeout, so the diagnostic threshold and deadlock detector cadence are coupled.
log_lock_waits is a SUPERUSER-context setting. Superuser or a role granted the appropriate SET privilege can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.
It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness.
Operational considerations
Changing log_lock_waits in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.
Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.
Changing deadlock_timeout without realizing it also changes when lock-wait diagnostics appear.
Workload guidance
OLAP: Analytical jobs can justify richer log_lock_waits telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline.
OLTP: Tune log_lock_waits against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture.
SMALL: Keep log_lock_waits useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency.
Version history 3
- PG 18 → 19changed
- PG 14 → 15changed
- PG 9.1 → 9.2changed
Related entries
Further reading
Definition snapshot: english-manuals:fb84a2d517a871d627bfaeebe46… · English manual source