// postgresql · logging & diagnostics

log_lock_waits

Log a message when a session waits longer than deadlock_timeout for a lock.

Padrão
off
Range
on, off
Restart needed
Não
Default checked on
PostgreSQL 18

O que faz

The log line names the waiting and the blocking process IDs, which is often the only record of a lock pile-up after it clears.

Valor padrão

off. off (PostgreSQL 18).

Check the current value

SHOW log_lock_waits;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'log_lock_waits';

Change it

SET log_lock_waits = on;   -- this session

ALTER SYSTEM SET log_lock_waits = on;
SELECT pg_reload_conf();

No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).

When to change it

Turn it on in production; the overhead is negligible and it explains intermittent slowness.

What can go wrong

Noisy on systems with constant short lock waits.

Questions about log_lock_waits

What is the default value of log_lock_waits in PostgreSQL?

off. off (PostgreSQL 18).

Does changing log_lock_waits require a restart?

No. No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).

When should I change log_lock_waits?

Turn it on in production; the overhead is negligible and it explains intermittent slowness.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check log_lock_waits on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.