On Mon, Jan 6, 2025 at 12:21 PM Stijn Sanders <stijnsand...@gmail.com> wrote:
> I've been using LibPQ to get data from PostgreSQL instances with great 
> success.
> I'm using PQsendQuery and PQgetResult, but noticed there's also 
> PQsetSingleRowMode.
> The documentation is clearly stating it only benefits a limited set of 
> scenario's, but I'm saddened that it can't help to get the first resulte of a 
> (longer running) query faster.

I haven't used single-row-mode myself, but I can tell you that using a
cursor instead of a statement allows you to reduce your
time-to-first-row. But at the expense of overall performance, i.e. in
my (limited) testing, getting the whole result-set in one go is faster
than getting the same rows via a cursor, even in varying chunk sizes.
Another alternative is to use COPY, which gets your the rows as they
come, but then you're on your own to "decode" the row and its
select-clause. FWIW. --DD


Reply via email to