Re: libpq: How are result sets fetched behind the scene? - Mailing list pgsql-sql

From Christian Barthel
Subject Re: libpq: How are result sets fetched behind the scene?
Date
Msg-id 87zhjg8eep.fsf@x230.onfire.org
Whole thread Raw
In response to Re: libpq: How are result sets fetched behind the scene?  (Sebastien FLAESCH <sf@4js.com>)
Responses Re: libpq: How are result sets fetched behind the scene?
List pgsql-sql
Sebastien FLAESCH <sf@4js.com> writes:

> Is the whole result set fetched to the client app, not matter what row
> number is provided to the first PQgetvalue() call (or similar API call
> on result set data or meta-data)?

I have tested this as well and came to the same result as you.
The entire result set seems to be fetched at once.
Attached is a test program: I have loaded 30MB of random strings
and did a simple SELECT on the random data.  I stopped the output
with getchar() and looked at the network traffic and the memory
usage with top(1).  Everything gets allocated and fetched at once
as far as I can see. 

However, I would not build an application that "depends" on this 
behavior.  I think that it is better to use a declared cursor and
use FETCH.
-- 
Christian Barthel <bch@online.de>


Attachment

pgsql-sql by date:

Previous
From: Karen Goh
Date:
Subject: How do I enabled Windows 10 to be able to run PSQL etc
Next
From: Rob Sargent
Date:
Subject: Re: How do I enabled Windows 10 to be able to run PSQL etc