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

From Robert Haas
Subject Re: Early WIP/PoC for inlining CTEs
Date
Msg-id CA+TgmobVMPX1wJxPaRQ=FZBzp-AQ=JWK=bzxztqwj=MsOsrnrA@mail.gmail.com
Whole thread Raw
In response to Re: Early WIP/PoC for inlining CTEs  (Andres Freund <andres@anarazel.de>)
Responses Re: Early WIP/PoC for inlining CTEs  (Mike Rylander <mrylander@gmail.com>)
Re: Early WIP/PoC for inlining CTEs  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: Early WIP/PoC for inlining CTEs  (Andreas Karlsson <andreas@proxel.se>)
List pgsql-hackers
On Fri, Jan 11, 2019 at 2:04 PM Andres Freund <andres@anarazel.de> wrote:
> > Maybe we could consider a more extensible syntax that is attached to
> > the contained SELECT rather than the containing WITH.  Then CTEs would
> > be less special; there'd be a place to put hints controlling top-level
> > queries, subselects, views etc too (perhaps eventually join hints,
> > parallelism hints etc, but "materialize this" would be just another
> > one of those things).  That'd be all-in.
>
> I think you have some purity arguments here, but the likelihood of us
> developing a full-blown solution is not that high, and the lack of
> inlinable CTEs is *really* hurting us. As long as the design doesn't
> block a full solution, if we go there, I think it's a very acceptable
> blemish in comparison to the benefits we'd get.

Also, it seems to me that this is properly a property of the
individual WITH clause, not the query as a whole.

I mean I suppose we could do

WITH or_with_out_you OPTIONS (materialized false) AS (SELECT 'mariah
carey') SELECT ...

That'd allow for extensibility, have the write scope, and look like
what we do elsewhere.  It looks a little less elegant than

WITH cte_name [[NOT] MATERIALIZED] AS (query) main_query...

...but maybe elegance for extensibility is a good trade.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Early WIP/PoC for inlining CTEs
Next
From: Robert Haas
Date:
Subject: Re: Prevent extension creation in temporary schemas