// postgresql · sql behavior

max_locks_per_transaction

Average number of object locks per transaction used to size the shared lock table.

Default
64
Range
10 to 2147483647
Restart needed
Yes
Default checked on
PostgreSQL 18

What it does

The lock table holds max_locks_per_transaction x (max_connections + max_prepared_transactions) entries. Touching many partitions or tables in one transaction (pg_dump, partitioned tables) uses one lock per relation.

Default value

64. 64 (PostgreSQL 18).

Check the current value

SHOW max_locks_per_transaction;

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

Change it

ALTER SYSTEM SET max_locks_per_transaction = 256;
-- applies only after a server restart

Server restart required (pg_settings.context is postmaster). ALTER SYSTEM only stages the new value in postgresql.auto.conf.

When to change it

When you see 'out of shared memory' with a hint to increase max_locks_per_transaction, typically with heavily partitioned tables or pg_dump of thousands of tables.

What can go wrong

Uses a little more shared memory; standbys need at least the primary's value.

Questions about max_locks_per_transaction

What is the default value of max_locks_per_transaction in PostgreSQL?

64. 64 (PostgreSQL 18).

Does changing max_locks_per_transaction require a restart?

Yes. Server restart required (pg_settings.context is postmaster). ALTER SYSTEM only stages the new value in postgresql.auto.conf.

When should I change max_locks_per_transaction?

When you see 'out of shared memory' with a hint to increase max_locks_per_transaction, typically with heavily partitioned tables or pg_dump of thousands of tables.

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

// one client for every engine

Check max_locks_per_transaction 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.