Re: BUG #17721: A completely unused CTE negatively affect Query Plan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17721: A completely unused CTE negatively affect Query Plan
Дата
Msg-id 2784036.1671042328@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #17721: A completely unused CTE negatively affect Query Plan  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #17721: A completely unused CTE negatively affect Query Plan
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> I've boiled down an issue we have in production to a simple query that can
> demonstrate it.  I've run this on 13,14 and 15 locally in a docker container
> with the same results.  If a CTE that is completely unexecuted exists in a
> subquery (or view in our production case) it affects the query plan VERY
> negatively.  The first explain shows a sequential scan, where the second
> explain shows an index scan, just by the existence of the (obviously)
> unexecuted CTE.

The presence of the CTE prevents flattening of the subquery.
If you don't like it, don't attach the CTE right there.

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17721: A completely unused CTE negatively affect Query Plan
Следующее
От: Mats Kindahl
Дата:
Сообщение: Re: Crash during backend start when low on memory