Re: More WITH - Mailing list pgsql-hackers

From Tom Lane
Subject Re: More WITH
Date
Msg-id 14173.1439954612@sss.pgh.pa.us
Whole thread Raw
In response to Re: More WITH  (Craig Ringer <craig@2ndquadrant.com>)
Responses Re: More WITH  (David Fetter <david@fetter.org>)
Re: More WITH  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Craig Ringer <craig@2ndquadrant.com> writes:
> On 18 August 2015 at 01:18, David Fetter <david@fetter.org> wrote:
>> FETCH [in WITH]

> I'd be a huge fan of this one. I'd love to see FETCH in subqueries,
> too. Currently doing anything like this requires an ugly PL/PgSQL
> wrapper.

> The cursor would have to be known at plan-time so it could be
> interrogated for its types.

That's barely the tip of the iceberg of the problems with this idea.

How many rows would be fetched from the cursor?  What row would it be
left on?  Whatever answer you give will be wrong from some perspective,
but particularly that of giving the planner any freedom-of-action
to optimize such a query.

More generally, what would you hope to accomplish with such a construct
that wouldn't be better done by writing the cursor's underlying query
directly in the WITH clause?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: How to compile, link and use a C++ extension
Next
From: Amit Kapila
Date:
Subject: Re: [DESIGN] ParallelAppend