Re: ECPG support for PQsetChunkedRowsMode()

From: Tim Fors <tim4stheenchanter(at)gmail(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: pgsql-interfaces(at)lists(dot)postgresql(dot)org
Subject: Re: ECPG support for PQsetChunkedRowsMode()
Date: 2025-11-21 21:35:51
Message-ID: CAOjiQ0C8O4g_KcVmOMq_+WJy+YCugBYe8A=RsZgHGP1nfhQG=g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Thanks for the info Daniel.

The reason I'm asking in the context of ECPG is this: When using a cursor
to FETCH one row of a result set at a time, it seems that the server
literally sends just one record to the client at a time, so using a cursor
in this context results in a lot of communication between the client and
server in order to process a large number of rows. I'm wondering if this is
accurate and if so, is there a way to improve performance by enabling some
kind of buffering or caching on the client side, while still allowing the
cursor to function as normal.

Note that ECPG supports using a C array as a host variable, and in that
case there's a bulk transfer of rows from the client to the server, so
performance is much better than getting the rows one at a time using a
cursor. However, AFAIK this is not standard coding practice - one expects
to be able to use the cursor to FETCH one row at a time, but still offer
good performance.

When I saw the addition of this "chunked rows mode" I thought perhaps it
would enable faster cursor usage. Since your answer indicates that it would
not, do you have any other recommendations to limit the effect of network
latency in order to speed up retrieval of rows via a cursor?

Thanks,

Tim

On Wed, Nov 19, 2025 at 1:44 PM Daniel Verite <daniel(at)manitou-mail(dot)org>
wrote:

> Tim Fors wrote:
>
> > The "chunked rows mode" appears to have been added to
> > libpq in V17.
> >
> > Does ECPG support this mode
>
> No. It's not clear how it would fit. This mode implies the use
> of PQsendQuery(), which does not seem to have an equivalent in
> ECPG.
>
> > are there plans to do so in the near future?
>
> Postgres as a project does not have a roadmap, but
> what's being worked on at any point in time can
> generally be tracked at https://commitfest.postgresql.org
>
>
> > Also, is there any data available on performance improvements that
> > one might see by using this mode?
>
> In [1], the time to retrieve rows by psql was compared between the
> the chunked rows mode and the cursor-based implementation, the
> latter being what would typically be used by an ECPG app.
>
>
>
> [1]:
> https://postgr.es/m/202bae70-f60d-4d24-a8d8-50b4ed638887@manitou-mail.org
>
>
> Best regards,
> --
> Daniel Vérité
> https://postgresql.verite.pro/
>

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Daniel Verite 2025-11-24 12:41:40 Re: ECPG support for PQsetChunkedRowsMode()
Previous Message Daniel Verite 2025-11-19 18:44:31 Re: ECPG support for PQsetChunkedRowsMode()