I'm wondering if the limit for the number of locks in PostgreSQL is fixed, or if it depends on the number of open connections. The docs say the limit is max_locks_per_transaction * (max_connections + max_prepared_transactions), while this article claims the limit is max_locks_per_transaction x number of currently open transactions.

I'm mainly trying to figure out if it makes any sense to monitor the total number of locks in PostgreSQL and trigger a warning on a fixed threshold. FWIW, we are not seeing any "out of memory" messages in the logs.


The first formula gives you the upper limit, the second formula give whats currently being used. Normally two different things, unless current usage is at the upper limit. Because DB's very often grow in usage, it doesn't hurt to monitor this. Just be sure to use sensible thresholds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.