Re: SOLVED - RE: Poor performance using CTE - Mailing list pgsql-performance

From Tom Lane
Subject Re: SOLVED - RE: Poor performance using CTE
Date
Msg-id 1159.1352943074@sss.pgh.pa.us
Whole thread Raw
In response to Re: SOLVED - RE: Poor performance using CTE  (Craig Ringer <craig@2ndQuadrant.com>)
List pgsql-performance
Craig Ringer <craig@2ndQuadrant.com> writes:
> I was looking through the latest spec drafts I have access to and
> couldn't find any reference to Pg's optimisation-fence-for-CTEs
> behaviour being required by the standard, though I've repeatedly seen it
> said that there is such a requirement.

I don't believe it's required by the standard (it's hard to see how it
could be, when query optimization is a topic outside the spec to start
with).  However, we allow INSERT/UPDATE/DELETE RETURNING inside WITH,
and for those I think you really need to treat WITH as an optimization
fence.  It's a lot more debatable for SELECT; there are some advantages
to providing a fence this way but there are definitely downsides too.
I could see adjusting that definition in the future, as we get more
experience with use of CTEs.

            regards, tom lane


pgsql-performance by date:

Previous
From: Craig Ringer
Date:
Subject: Re: SOLVED - RE: Poor performance using CTE
Next
From: Andrew Dunstan
Date:
Subject: Re: SOLVED - RE: Poor performance using CTE