Re: Will PQsetSingleRowMode get me results faster? - Mailing list pgsql-general

From Dominique Devienne
Subject Re: Will PQsetSingleRowMode get me results faster?
Date
Msg-id CAFCRh-9UGi+aKgC_VDvMrAZkqQ3X18xBD_De67qknQ1gf8J9bw@mail.gmail.com
Whole thread Raw
In response to Will PQsetSingleRowMode get me results faster?  (Stijn Sanders <stijnsanders@gmail.com>)
List pgsql-general
On Mon, Jan 6, 2025 at 12:21 PM Stijn Sanders <stijnsanders@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
helpto 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



pgsql-general by date:

Previous
From: Nick
Date:
Subject: Re: Questions about the Debian Package version of pgAdmin
Next
From: Kiran K V
Date:
Subject: Query related to Logical Replication using test_decoding and unchanged-toast-datum