# deadlock_timeout

> deadlock_timeout — Sets the time to wait on a lock before checking for deadlock. Observed in PG9.0–19 Beta 3; its last measured boot default is 1 s in PG19 Beta 3, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
---

> [!NOTE]
> **Fact — official short description:** “Sets the time to wait on a lock before checking for deadlock.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `superuser` | Settable at runtime by a superuser |
| Unit | `ms` | Raw unit |
| Range | `1` – `2147483647` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Lock Management | Upstream classification |
| Latest boot value | `1000` | 1 s |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `1000` | `ms` | 1 s |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

Sets the time to wait on a lock before checking for deadlock. A superuser or a role granted SET privilege can change it for the relevant session or configuration scope.

PostgreSQL waits this long before running the comparatively expensive deadlock detector. The same interval controls lock-wait logging when log_lock_waits is enabled, so lowering it improves diagnostics and deadlock response at the cost of more checks during ordinary contention.

Monitor and change deadlock_timeout together with log_lock_waits, lock_timeout, max_locks_per_transaction. Validate on the relevant server role and real workload, then use its superuser context to choose session change, reload, or restart; a historical boot default is not the current effective value.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Calibrate deadlock_timeout from lock-wait logs, objects touched, and the concurrency bound. Fix long transactions and access ordering before adding shared memory or changing detection granularity. |
| OLAP | Partitioned queries, bulk DDL, and SERIALIZABLE reports may touch many objects; test the worst plan, not only an average transaction. |
| Small nodes | Defaults are usually sufficient. If raising a startup lock-table setting, account for max_connections, prepared transactions, and standby consistency together. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | `50ms` | different | `50ms` |
| OLAP | `50ms` | different | `50ms` |
| CRIT | `50ms` | different | `50ms` |
| TINY | `50ms` | different | `50ms` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 50ms (dcs); OLAP: PG9.0–19 Beta 3 = 50ms (dcs); CRIT: PG9.0–19 Beta 3 = 50ms (dcs); TINY: PG9.0–19 Beta 3 = 50ms (dcs). Advice, pending human review — Editorial interpretation, pending human maintainer review: the override appears intended to detect true deadlocks and emit lock-wait diagnostics faster than upstream; confirm it against the current Pigsty templates, hardware fixture, and operational guarantees before publication.

## Common pitfalls {#common-pitfalls}

- Reading an average shared-memory sizing value as a hard per-transaction limit.
- Raising it without the multiplier from connections and prepared transactions.
- Expanding lock memory instead of fixing long transactions, access order, or partition explosion.
- Ignoring compatible startup lock capacity on standbys.

## Related parameters {#related-parameters}

[`log_lock_waits`](/parameters/log-lock-waits/) · [`lock_timeout`](/parameters/lock-timeout/) · [`max_locks_per_transaction`](/parameters/max-locks-per-transaction/) · [`max_pred_locks_per_transaction`](/parameters/max-pred-locks-per-transaction/) · [`max_pred_locks_per_page`](/parameters/max-pred-locks-per-page/) · [`max_pred_locks_per_relation`](/parameters/max-pred-locks-per-relation/)

## References {#references}

- [PostgreSQL 19 Beta 3 — deadlock_timeout](https://www.postgresql.org/docs/19/runtime-config-locks.html#GUC-DEADLOCK-TIMEOUT)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
