From: | Sebastien FLAESCH <sf(at)4js(dot)com> |
---|---|
To: | pgsql-sql(at)lists(dot)postgresql(dot)org |
Subject: | libpq: How are result sets fetch behind the scene? |
Date: | 2019-08-29 16:32:44 |
Message-ID: | 6f2f210b-53e6-f350-4850-83f49b2a1354@4js.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all,
We are using libpq in our C program.
I was wondering how the client lib / protocol manage to fetch the result set to the client app memory.
Is there some optimization ?
Are rows fetched in sequence until the requested row?
I mean if I do a SELECT that produces a huge result set, and then call PQgetvalue() with a row_number = 5000, are all 5000 rows fetched from the
server or is there some smart fast-forward done because I did not ask the 4999 previous rows?
We know about server cursors (declare + fetch forward), and we do already fetch blocks of rows with this.
But server cursors are slow (and certainly use more server resources), compared to direct SELECT execution.
So we are wondering what would be the impact in terms of resources on the client application.
Is there any doc link or blog that would explain best practices with libpq result set programming?
Thanks!
Seb
From | Date | Subject | |
---|---|---|---|
Next Message | Sebastien FLAESCH | 2019-08-29 16:39:13 | Re: libpq: How are result sets fetched behind the scene? |
Previous Message | Pavel Stehule | 2019-08-23 11:53:45 | Re: Ordering of arrays |