Re: [HACKERS] CTE inlining
От | Craig Ringer |
---|---|
Тема | Re: [HACKERS] CTE inlining |
Дата | |
Msg-id | CAMsr+YG1O7hdbSWozO4fyTNf9pcXQEv=1Om1=THCJwQJFow97g@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] CTE inlining (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: [HACKERS] CTE inlining
|
Список | pgsql-hackers |
On 5 May 2017 02:52, "Tom Lane" <tgl@sss.pgh.pa.us> wrote:
>>> I haven't been able to follow this incredibly long thread, so please
>>> excuse me if way off base, but are we talking about that a CTE would be
>>> silently be rewritten as an inline expression potentially unless it is
>>> decorated with some new syntax?> I agree with this, but there's a difference between "executed exactlyI haven't been keeping close tabs either, but surely we still have to have
> once" and "producing the same result as if executed exactly once".
> I may be misunderstanding what other people proposed in this thread, but
> I think the plan was to only inline CTEs where we know it won't change
> the results, etc. So e.g. CTEs with volatile functions would not get
> inlined, which includes nextval() for example.
the optimization fence in (at least) all these cases:
* CTE contains INSERT/UPDATE/DELETE
* CTE contains SELECT FOR UPDATE/SHARE (else the set of rows that get
locked might change)
* CTE contains volatile functions
I'm willing to write off cases where, eg, a function should have been
marked volatile and was not. That's user error and there are plenty
of hazards of that kind already. But if the optimizer has reason
to know that discarding the fence might change any query side-effects,
it mustn't.
I think everyone is in total agreement there.
В списке pgsql-hackers по дате отправления: