Re: [HACKERS] libpq: why we need to fetch all rows? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] libpq: why we need to fetch all rows?
Date
Msg-id 6a0756d72b7d719bd15bf52c88117bec
Whole thread Raw
In response to [HACKERS] libpq: why we need to fetch all rows?  (Alexander Demenshin <aldem@techie.com>)
List pgsql-hackers
>
> Does the portal store all the rows at the backend and feed them one by one
> to the client, or does it go out to disk to get new rows?

Check out PerformPortalFetch().  Looks like it creates a memory area for
each portal, and allows you to move around in it.  This is probably why
a transaction is needed, because the memory is probably in a
transaction-specific pool that gets automatically freed at the end of
transactions.

But then if you look at the ExecutorRun() call, it appears to re-execute
the entire query for each fetch, which is a terrible waste.  So it may
be only saving the executor 'plan' in memory, and reexecuting it for
each fetch, rather than saving off the result of the query.

Perhaps someone can comment on this.  Vadim is on vacation until July
24th.

- --
Bruce Momjian
maillist@candle.pha.pa.us

------------------------------

pgsql-hackers by date:

Previous
From: aixssd!darrenk@abs.net (Darren King)
Date:
Subject: Re: [HACKERS] Problem with copying abstimes
Next
From: The Hermit Hacker
Date:
Subject: date format: Canada same as European or US?