public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tim Herren <[email protected]>
To: [email protected] <[email protected]>
Subject: Maximum amount of pg_locks
Date: Wed, 28 Jan 2026 20:12:01 +0000
Message-ID: <hS-XH0n2SemZiCabUk02t2mKBBLxiFFF-iA7u_RIp8HuTPrFt1T3J_ljcMcYV7syotOSkKM7zV9jwTVcnkz356oltoxkLJjXvMIObTMP254=@protonmail.ch> (raw)
Hi
I'm trying to wrap my head around the way the calculation for the maximum amount of locks works in postgres 16.11
I already came to the understanding that the maximum amount of locks are not on a transaction basis, but rather influenced by the setting "max_locks_per_transaction" and the "max_connections".
I'm saying influenced rather than calculated because on my server a simple multiplication of those two values, set at 512 and 180 respectively gives 92160.
Yet I regularly observe around 119k locks during my backup using "pg_dump -Fc".
postgres=# SELECT
locktype,
mode,
count(*)
FROM pg_locks
GROUP BY 1, 2
ORDER BY 3 DESC;
locktype | mode | count
------------+-----------------+--------
relation | AccessShareLock | 119948
virtualxid | ExclusiveLock | 2
(2 rows)
The database I'm backing up at that time contains 242 schemas and each has around 500 relations (a mix of tables and sequences).
So that matches pretty well.
I've verified that my configured setting is enough in the sense that I get a usable backup and my database remains operational during the backup period. Non the less I would like to understand where that difference comes from and how close to the "actual limit" I am.
Please let me know if this needs more information.
Thanks
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Maximum amount of pg_locks
In-Reply-To: <hS-XH0n2SemZiCabUk02t2mKBBLxiFFF-iA7u_RIp8HuTPrFt1T3J_ljcMcYV7syotOSkKM7zV9jwTVcnkz356oltoxkLJjXvMIObTMP254=@protonmail.ch>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox