lock_timeout
No restart — settable per sessiontuned by pgconfiguratortime (ms); 0 disables
Caps how long a statement waits to acquire a lock before giving up.
What pgconfigurator would set
32 GB · 8 vCPU · NVMe · OLTP
Computing…
Tune for your exact server → /tunecomputed in your browser · nothing uploaded
What it does
lock_timeout limits the time a statement will wait for a lock; if it can't get the lock in time, it errors instead of blocking indefinitely. Unlike statement_timeout it only counts lock-wait time, not execution.
How to tune it
Invaluable for safe schema migrations: set a short lock_timeout before an ALTER TABLE so it fails fast rather than queuing behind a long transaction and blocking everything behind it. For normal queries it's often left at 0 and handled by statement_timeout.
FAQ
- How do I run schema changes without blocking the app?
- Set a short lock_timeout (e.g. SET lock_timeout = '2s') before the DDL so it backs off instead of holding a lock queue. Retry with backoff. This stops one ALTER from stalling every query waiting behind it.