Re: CTE optimization fence on the todo list? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: CTE optimization fence on the todo list?
Date
Msg-id 23258.1349100421@sss.pgh.pa.us
Whole thread Raw
In response to Re: CTE optimization fence on the todo list?  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: CTE optimization fence on the todo list?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Merlin Moncure <mmoncure@gmail.com> writes:
> I'm wondering if there are any technical/standards constraints that
> are behind the fencing behavior.

I think the key reason is that we don't want partial execution of DML
operations (ie, INSERT/UPDATE/DELETE inside a WITH).  The fencing
behavior was put in originally because we foresaw adding DML later.

We could possibly relax the rule for WITH SELECT only, but it would
be rather inconsistent, not to mention unpleasant for all the people
who are relying on the current behavior for one reason or another.

Another issue is that if the CTE is scanned multiple times by the outer
query, you really can't optimize it on the basis of any one call site.
        regards, tom lane



pgsql-hackers by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Re: Doc patch, further describe and-mask nature of the permission system v2
Next
From: Tom Lane
Date:
Subject: Re: Hash id in pg_stat_statements