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

From Andreas Karlsson
Subject Re: Early WIP/PoC for inlining CTEs
Date
Msg-id 00818be9-2f63-f584-efcd-d97ee0662905@proxel.se
Whole thread Raw
In response to Re: Early WIP/PoC for inlining CTEs  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Early WIP/PoC for inlining CTEs  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Early WIP/PoC for inlining CTEs  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On 1/11/19 8:10 PM, Robert Haas wrote:
> WITH cte_name [[NOT] MATERIALIZED] AS (query) main_query...

Hm, when would one want "NOT MATERIALIZED"? I am not sure I see the 
usefulness of forcing inlining other than if we by default do not inline 
when a CTE is referenced multiple times.

Do you imaging it working something like the below?

1. Default

# Not inlined

- Referenced multiple times
- Includes FOR UPDATE|SHARE
- Includes volatile functions
- Recurisve
- DML

# Inlined

- Simple case (no side effects, referenced once)

2. MATERIALIZED

# Not inlined

- Everything

# Inlined

- (none)

3. NOT MATERIALIZED

# Not inlined

- Recursive
- DML

# Inlined

- Everything else

Andreas



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ArchiveEntry optional arguments refactoring
Next
From: Andreas Karlsson
Date:
Subject: Re: Feature: temporary materialized views