From: | Dominique Devienne <ddevienne(at)gmail(dot)com> |
---|---|
To: | Stijn Sanders <stijnsanders(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Will PQsetSingleRowMode get me results faster? |
Date: | 2025-01-06 11:54:41 |
Message-ID: | CAFCRh-9UGi+aKgC_VDvMrAZkqQ3X18xBD_De67qknQ1gf8J9bw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Jan 6, 2025 at 12:21 PM Stijn Sanders <stijnsanders(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kiran K V | 2025-01-06 14:19:47 | Query related to Logical Replication using test_decoding and unchanged-toast-datum |
Previous Message | Nick | 2025-01-06 03:27:51 | Re: Questions about the Debian Package version of pgAdmin |