public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Tim Fors <[email protected]>
Cc: [email protected]
Subject: Re: Client-server communication for FETCH
Date: Wed, 03 Dec 2025 13:41:48 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAOjiQ0C7NEV9ZBFxbM6KgXnzquaUY3MrN1x8vz_tv7uXac0UwQ@mail.gmail.com>
References: <CAOjiQ0C7NEV9ZBFxbM6KgXnzquaUY3MrN1x8vz_tv7uXac0UwQ@mail.gmail.com>
Tim Fors <[email protected]> writes:
> I have a simple C program using libpq V18 to FETCH one row at a time (see
> below). Does the server send multiple rows to the client where they are
> cached for satisfying the FETCH statements, or does it just send one row at
> a time since that's all that each FETCH statement is asking for?
It's sending one row at a time. You could improve that by asking
for more than one row ("FETCH n" not just "FETCH"), but you'd have
to iterate over the rows returned by each command.
Another alternative is to forget about using a cursor, tell the
server to just execute the query, but use libpq's "chunked results"
mode to process rows before all of the query result has arrived.
See
https://www.postgresql.org/docs/current/libpq-single-row-mode.html
> I have done extensive searching to try and find the definitive answer to
> this. The searches indicate that libpq supports the concept of a
> client-side cursor, where it has a cache of rows sent by the server and
> uses that cache to perform each FETCH, but I'd like to be able to verify
> whether this is true or not.
Don't know where you read that, but it's not true of libpq. There
might be other Postgres client libraries that can do that.
regards, tom lane
view thread (4+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Client-server communication for FETCH
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox