max_locks_per_transaction
Sets the maximum number of locks per transaction.
How you change it
Restart required
Defaults and ranges on this page were read from pg_settings on live PostgreSQL 18.4. Treat older majors as needing their own check before you copy a value.
The shared lock table is sized on the assumption that at most "max_locks_per_transaction" objects per server process or prepared transaction will need to be locked at any one time.
What this means
Sizes the shared lock table: the server can track about this many object locks per connection slot on average (locks are shared from a common pool). Transactions that touch many partitions or objects at once -- a query over a big partitioned table, or a large schema migration -- can exhaust it and raise 'out of shared memory'.
When it matters
Raise it when you run queries or DDL that touch many partitions/objects in one transaction.
| Default | 64 |
|---|---|
| Range | 10 – 2147483647 |
| Type | integer |
| Change scope | Restart required |
| Category | Locking |
SHOW max_locks_per_transaction;Tradeoffs
- • Too low: 'out of shared memory' / 'out of shared lock space' on partition-heavy queries.
- • Sized against max_connections, so the real pool is this value times the connection slots.
- • Changing it requires a restart.