Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Jakub Wartak <jakub.wartak@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2023-01-04T15:57:28Z
Lists: pgsql-hackers
On Wed, Jan 4, 2023 at 10:22 AM Daniel Verite <daniel@manitou-mail.org> wrote:
> A solution would be for psql to use PQsetSingleRowMode() to retrieve
> results row-by-row, as opposed to using a cursor, and then allocate
> memory for only FETCH_COUNT rows at a time. Incidentally it solves
> other problems like queries containing multiple statements, that also
> fail to work properly with cursors, or UPDATE/INSERT... RETURNING.. on
> large number of rows that could also benefit from pagination in
> memory.

Is there any reason that someone hasn't, like, already done this?

Because if there isn't, we should really do this. And if there is,
like say that it would hurt performance or something, then we should
come up with a fix for that problem and then do something like this.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



Commits

  1. Further review for re-implementation of psql's FETCH_COUNT feature.

  2. Re-implement psql's FETCH_COUNT feature atop libpq's chunked mode.

  3. Support retrieval of results in chunks with libpq.

  4. Attempt to fix newly added Memoize regression test