Re: BUG #17721: A completely unused CTE negatively affect Query Plan - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17721: A completely unused CTE negatively affect Query Plan
Date
Msg-id 2998993.1671058060@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17721: A completely unused CTE negatively affect Query Plan  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17721: A completely unused CTE negatively affect Query Plan
List pgsql-bugs
Nathaniel Hazelton <nathaniel@sturdyai.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



pgsql-bugs by date:

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