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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nathaniel Hazelton <nathaniel(at)sturdyai(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17721: A completely unused CTE negatively affect Query Plan
Date: 2022-12-14 22:47:40
Message-ID: 2998993.1671058060@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Nathaniel Hazelton <nathaniel(at)sturdyai(dot)com> writes:
> The CTE in that location was emulating a view in which we have a CTE -
> which responds the same way. Does this mean CTEs can never be used in
> views that could be flattened without affecting performance?

You've got a view with an unused CTE? Why?

But at any rate, yes, the presence of a CTE is an optimization
fence: we can't flatten the subquery containing it without losing
the query level at which the CTE should be evaluated. Perhaps there
are special cases where that could be relaxed, but nobody's tried
very hard.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alex Richman 2022-12-14 22:59:26 Segfault while creating logical replication slots on active DB 14.6-1 + 15.1-1
Previous Message Daniel Gustafsson 2022-12-14 22:30:54 Re: BUG #17720: pg_dump creates a dump with primary key that cannot be restored, when specifying 'using index ...'