PostgreSQL

Excessive work_mem allocation can exhaust system memory under concurrent load

critical
Resource ContentionUpdated Jan 21, 2026
Technologies:
How to detect:

work_mem is allocated per operation (not per connection), and can be multiplied by concurrent operations. With max_connections=200, work_mem=256MB, and complex queries using multiple sort/hash operations, total memory usage could reach 200 * 256MB * operations_per_query, far exceeding available RAM.

Recommended action:

Calculate max potential usage: max_connections * work_mem * operations_per_query. Start conservative (64MB) and increase only if needed. Monitor actual memory usage patterns. For complex analytical queries, consider setting work_mem per-session rather than globally.