Re: [HACKERS] CTE inlining - Mailing list pgsql-hackers

From David Rowley
Subject Re: [HACKERS] CTE inlining
Date
Msg-id CAKJS1f8ma3icER32g8HM33Rp4mTp90Ucv8q0CkitY3s6EE20aw@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] CTE inlining  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
On 13 May 2017 at 08:39, Bruce Momjian <bruce@momjian.us> wrote:
> To summarize, it seems we have two options if we want to add fence
> control to CTEs:
>
> 1.  add INLINE to disable the CTE fence
> 2.  add MATERIALIZE to enable the CTE fence

I think #1 is out of the question.

What would we do in cases like:

WITH INLINE cte AS (SELECT random() a)
SELECT * FROM cte UNION SELECT * FROM cte;

I assume we won't want to inline when the CTE query contains a
volatile function, and we certainly won't in cases like:

WITH INLINE cte AS (DELETE FROM a RETURNING *)
INSERT INTO b SELECT * from cte WHERE cte.value > 5;

We'd be certain to receive complaints from disgruntled users about
"Why is this not inlined when I specified INLINE?"

#2 does not suffer from that.

-- David Rowley                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: [HACKERS] Duplicate usage of tablespace location?
Next
From: amul sul
Date:
Subject: Re: [HACKERS] [POC] hash partitioning