1. https://pganalyze.com/docs/log-insights/server/S5
More generally, often out of memory occurs when operating a combination of too high work_mem
together with a high number of active connections.
If you are getting frequent OOM errors a good first step is to reduce work_mem
, which should improve stability at the cost of more sort/hash operations going to disk instead.
It also often makes sense to monitor the number of active connections at the time of the issue, e.g. through pganalyze's Connection Tracing feature.
Additionally, if you absolutely need more RAM to work with, you can evaluate reducing shared_buffers
to provide more available RAM for memory directly used by connections. This should be done carefully, and whilst actively watching Buffer Cache Hit Ratio statistics