Thread: Re: Using a lot of memory in each session.

Re: Using a lot of memory in each session.

From
Laurenz Albe
Date:
On Tue, 2024-09-24 at 16:58 +0900, DBA wrote:
> We set shared_buffer = 70GB, max_connections = 300, work_mem = 300MB.
>
> We thought the session memory could be adjusted with the work_mem variable, but no.
> noticed that each session consumed more than 500MB.

work_mem limits the memory used by a single execution plan step, so a single
backend can use way more memory.
Moreover, there is hash_mem_multiplier, which defaults to 2 in v15, so a
hash may use twice as much memory.

You didn't tell us how much RAM you have, but your setting of shared_buffers
is probably too high, and you most likely should also reduce work_mem,
particularly if you allow hundreds of connections.

Anyway, I see no bug here.

Yours,
Laurenz Albe