Yes you're right, idle connection do not use temp_buffers or work_mem.
I was trying to gather everything relevant to resources per connection. I'm not saying work_mem caused our problem.
I was trying to gather everything relevant to resources per connection. I'm not saying work_mem caused our problem.
It means that potentially every connection may at some point use this amount of memory, but idle connections will not. If you have 20 busy connections and 350 idle ones, at most 20 x temp_buffers will be used and there is no benefit from PGbouncer in this regard. If you have 370 busy connections, all of them might use temp_buffers and your tradeoff can be 370 concurrently executing queries at higher memory cost vs. e.g. 20 concurrently executing queries via PGbouncer at lower memory cost and 350 stalled queries with potentially high latency.
> We have many idle connections.
In this case, you will not have any issues with memory use from temp_buffers, work_mem ...