Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pD6lJ-00050E-Ag for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Jan 2023 16:37:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pD6lG-0005i3-D8 for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Jan 2023 16:37:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pD6lG-0005hp-47 for pgsql-hackers@lists.postgresql.org; Wed, 04 Jan 2023 16:37:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pD6l9-0004H5-8N for pgsql-hackers@postgresql.org; Wed, 04 Jan 2023 16:37:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 304GapWI2097214; Wed, 4 Jan 2023 11:36:51 -0500 From: Tom Lane To: Robert Haas cc: Daniel Verite , Jakub Wartak , PostgreSQL Hackers Subject: Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs In-reply-to: References: <3a3451a2-7d05-4dd7-b7ac-e75d2accf327@manitou-mail.org> Comments: In-reply-to Robert Haas message dated "Wed, 04 Jan 2023 10:57:28 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2097212.1672850211.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 04 Jan 2023 11:36:51 -0500 Message-ID: <2097213.1672850211@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Wed, Jan 4, 2023 at 10:22 AM Daniel Verite = 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. > Is there any reason that someone hasn't, like, already done this? As you well know, psql's FETCH_COUNT mechanism is far older than single-row mode. I don't think anyone's tried to transpose it onto that. I agree that it seems like a good idea to try. There will be more per-row overhead, but the increase in flexibility is likely to justify that. regards, tom lane