53200: out_of_memory
PostgreSQLWhat does it mean?
The server could not allocate the memory required for an operation. A backend process or the whole server is under memory pressure.
Why does it happen?
work_mem/maintenance_work_mem set too high and multiplied by high concurrency, too many hash/sort operations in a single query, an excessive number of connections, a memory leak, or pressure from the operating system OOM killer.
How to fix it
Check the memory context in the server log and traces of the OOM killer. Set work_mem sensibly, taking query and concurrency counts into account (it is allocated separately for each sort/hash). Limit the number of connections with pooling. Review the operating system memory/overcommit settings. Optimize heavy queries to lower their memory requirement.