pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Radoslav Nedyalkov <rnedyalkov@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: how to limit statement memory allocation
Date: Tue, 09 Mar 2021 11:03:40 -0500
Message-ID: <2022857.1615305820@sss.pgh.pa.us> (raw)
In-Reply-To: <CANhtRiabb+qeeRp--iBMrzWEJWJQoOOqS2-JaKA-3PY7CULXuw@mail.gmail.com>
References: <CANhtRiabb+qeeRp--iBMrzWEJWJQoOOqS2-JaKA-3PY7CULXuw@mail.gmail.com>

Radoslav Nedyalkov <rnedyalkov@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





view thread (7+ messages)  latest in thread

Message-ID: <2022857.1615305820@sss.pgh.pa.us>
Permalink:  ../2022857.1615305820@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2022857.1615305820@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rnedyalkov@gmail.com
  Subject: Re: how to limit statement memory allocation
  In-Reply-To: <2022857.1615305820@sss.pgh.pa.us>
  References: <CANhtRiabb+qeeRp--iBMrzWEJWJQoOOqS2-JaKA-3PY7CULXuw@mail.gmail.com> <2022857.1615305820@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox