Configuration parameter

max_locks_per_transaction — PostgreSQL Configuration Parameter

Category Locks Default 64 Unit boolean / enum / numeric Change scope Restart required

Average lock slots reserved per transaction.

At a glance

Property Value
Parameter max_locks_per_transaction
Category Locks
Default 64
Value type boolean / enum / numeric
Change scope Restart required

What it does

Sizes the shared lock table (= this x (max_connections + max_prepared_transactions)). It is an average, not a hard per-transaction cap.

How to apply a change

Requires a full server restart (postmaster context). Set it in postgresql.conf and restart PostgreSQL.

Inspect the current value and source with SHOW max_locks_per_transaction; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'max_locks_per_transaction';.

Tuning guidance

Raise (e.g. 256-1024) when touching many partitions/tables in one transaction throws “out of shared memory … increase max_locks_per_transaction” (SQLSTATE 53200). Requires restart.

Reference

PostgreSQL documentation — Locks configuration.

Was this helpful?

← All configuration parameters