Radoslav Nedyalkov <rnedyal...@gmail.com> writes: > Occasionally we get bad queries on our db that consume a lot of memory. > These typically are full joins by mistake or just too large result sets. > My understanding is these should go to a temp file but apparently memory > allocation is preferred.
Perhaps the accumulation is happening on the client side? libpq doesn't have any provision for spilling a result set to disk. If that's it, you could consider revising your application to read results row-at-a-time, although that might require a good deal of effort. https://www.postgresql.org/docs/current/libpq-single-row-mode.html regards, tom lane