From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nathaniel Hazelton <nathaniel@sturdyai.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17721: A completely unused CTE negatively affect Query Plan
Date: Wed, 14 Dec 2022 17:47:40 -0500
Message-ID: <2998993.1671058060@sss.pgh.pa.us> (raw)
In-Reply-To: <BD7EBA1F-4FB7-43CC-A70B-42439454EAE5@sturdyai.com>
References: <17721-a660b93948b165a7@postgresql.org>
<2784036.1671042328@sss.pgh.pa.us>
<BD7EBA1F-4FB7-43CC-A70B-42439454EAE5@sturdyai.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, nathaniel@sturdyai.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17721: A completely unused CTE negatively affect Query Plan
In-Reply-To: <2998993.1671058060@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox