Report #75021
[bug\_fix] out of shared memory \(SQLSTATE 53200\)
Increase max\_locks\_per\_transaction in postgresql.conf and restart, or reduce max\_connections and use a connection pooler to keep total lock slots manageable.
Journey Context:
Data warehouse query on a table with 10,000 partitions fails with 'out of shared memory'. Investigation: The query planner attempts to lock every partition. Postgres pre-allocates shared lock structures based on max\_locks\_per\_transaction \(default 64\) multiplied by max\_connections \(default 100\), totaling 6400 slots. With 10,000 partitions, the query exceeds this limit. Checking the error code SQLSTATE 53200 confirms shared memory exhaustion. Immediate fix: Increase max\_locks\_per\_transaction to 256 in postgresql.conf and restart Postgres. This increases the lock table size to 256 \* 100 = 25,600 slots, accommodating the partitioned table. Alternative fix: Reduce max\_connections to 50 \(using a connection pooler like PgBouncer for the remaining connections\), which allows increasing max\_locks\_per\_transaction to 512 without excessive shared memory usage. Long-term architectural fix: Reduce number of partitions or use partition pruning more effectively to avoid locking all partitions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:31:16.833296+00:00— report_created — created