Re: where does postgres keep the query result until it is returned? - Mailing list pgsql-general

From Tom Lane
Subject Re: where does postgres keep the query result until it is returned?
Date
Msg-id 10246.1284732820@sss.pgh.pa.us
Whole thread Raw
In response to Re: where does postgres keep the query result until it is returned?  (Sam Mason <sam@samason.me.uk>)
Responses Re: where does postgres keep the query result until it is returned?  (Willy-Bas Loos <willybas@gmail.com>)
List pgsql-general
Sam Mason <sam@samason.me.uk> writes:
> On Fri, Sep 17, 2010 at 02:14:57PM +0100, Sam Mason wrote:
>> Postgres, the server software, will spill large results (and any
>> intermediate working sets) to disk automatically as needed.  I believe
>> any memory allocated for this task will be up to work_mem in size.

> That wasn't very clear was it; when I said "this task" I meant the task
> of accumulating results before things spill.

If the question was about the final query result sent to the client:
we don't spill that to disk, nor "hold" it anywhere.  The backend
sends it to the client on-the-fly as each row is generated.  It's
the client's responsibility to cope if the result set is huge.
(As you noted, libpq is none too bright about that.)

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: What's wrong with this query?
Next
From: Willy-Bas Loos
Date:
Subject: Re: where does postgres keep the query result until it is returned?