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
.
If you are getting frequent OOM errors a good first step is to reducework_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
用一个例子来演示会更加清晰