pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nico Williams <nico@cryptonector.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: Jeremy Finzel <finzelj@gmail.com>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Early WIP/PoC for inlining CTEs
Date: Wed, 25 Jul 2018 13:39:19 -0500
Message-ID: <20180725183918.GP5695@localhost> (raw)
In-Reply-To: <21958.1532476669@sss.pgh.pa.us>
References: <87sh48ffhb.fsf@news-spur.riddles.org.uk>
	<CAMa1XUiQqZmUDYnQCdHejsy35qXC3-YQeVmbBi9qdOW7QYY_nA@mail.gmail.com>
	<20180724231010.quiaae5qyfrreiyj@alap3.anarazel.de>
	<21487.1532476159@sss.pgh.pa.us>
	<20180724235416.c7c4az6kjxyszkgt@alap3.anarazel.de>
	<21958.1532476669@sss.pgh.pa.us>

On Tue, Jul 24, 2018 at 07:57:49PM -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > On 2018-07-24 19:49:19 -0400, Tom Lane wrote:
> >> However, a singly-referenced SELECT CTE could reasonably be treated as
> >> equivalent to a sub-select-in-FROM, and then you would have the same
> >> mechanisms for preventing inlining as you do for those cases,
> >> e.g. OFFSET 0.  And sticking in OFFSET 0 would be backwards-compatible
> >> too: your code would still work the same in older releases, unlike if
> >> we invent new syntax for this.
> 
> > I still think this is just doubling down on prior mistakes.
> 
> Not following what you think a better alternative is?  I'd be the
> first to agree that OFFSET 0 is a hack, but people are used to it.
> 
> Assuming that we go for inline-by-default for at least some cases,
> there's a separate discussion to be had about whether it's worth
> making a planner-control GUC to force the old behavior.  I'm not
> very excited about that, but I bet some people will be.

It is widely known that CTEs in PG are optimizer barriers.

That actually is useful, and I do make use of that fact (though I'm not
proud of it).

My proposal is that PG add an extension for specifying that a CTE is to
be materialized (barrier) or not (then inlined).

Nico
-- 




view thread (112+ messages)  latest in thread

Message-ID: <20180725183918.GP5695@localhost>
Permalink:  ../20180725183918.GP5695@localhost/
Also on:    postgresql.org/message-id/20180725183918.GP5695@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nico@cryptonector.com, tgl@sss.pgh.pa.us, andres@anarazel.de, finzelj@gmail.com, andrew@tao11.riddles.org.uk
  Subject: Re: Early WIP/PoC for inlining CTEs
  In-Reply-To: <20180725183918.GP5695@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox