Re: Early WIP/PoC for inlining CTEs - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: Early WIP/PoC for inlining CTEs
Date
Msg-id 87woqvaj1w.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: Early WIP/PoC for inlining CTEs  (David Fetter <david@fetter.org>)
List pgsql-hackers
>>>>> "David" == David Fetter <david@fetter.org> writes:

 >> Consider the difference between (in the absence of CTE inlining):
 >> 
 >> -- inline subquery with no optimization barrier (qual may be pushed down)
 >> select * from (select x from y) s where x=1;

 David> ...and doesn't need to materialize all of y,

 >> -- inline subquery with optimization barrier (qual not pushed down)
 >> select * from (select x from y offset 0) s where x=1;
 >> 
 >> -- CTE with materialization
 >> with s as (select x from y) select * from s where x=1;

 David> while both of these do.

The non-CTE one has to _evaluate_ the whole of the "s" subquery, but it
doesn't have to actually store the result, whereas the CTE version needs
to put it all in a tuplestore and read it back.

-- 
Andrew (irc:RhodiumToad)


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Assertion failure with ALTER TABLE ATTACH PARTITION withlog_min_messages >= DEBUG1
Next
From: Tom Lane
Date:
Subject: Re: Performance improvements for src/port/snprintf.c