Hi, On Fri, Oct 13, 2023 at 03:06:57PM +0200, Jean-Christophe Boggio wrote: > On my dev laptop, I have ~40GB free RAM. When launching a heavy calculation > in PostgreSQL (within a stored procedure), it consumes as much memory as is > available and then gets killed by OOM. There is only one connected session. > > I have the following settings, which look reasonable (to me): > > shared_buffers = 512MB # min 128kB That's not a lot. > work_mem = 1GB # min 64kB On the other hand, that's a lot. So if that query is run in parallel and has a lot of different things it does, it might use work_mem several times over, resulting in a lot of used memory. So first thing to try would be to lower work_mem to someting much lower like 64MB or 128MB. > This is PostgreSQL 14.7 running on Ubuntu 23.04 The other thing you can try is to see whether turning jit off (or just jit_inline_above_cost = -1) is helping. Michael