From: Tom Lane <tgl@sss.pgh.pa.us>
To: nh.dev@sturdy.ai
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17721: A completely unused CTE negatively affect Query Plan
Date: Wed, 14 Dec 2022 13:25:28 -0500
Message-ID: <2784036.1671042328@sss.pgh.pa.us> (raw)
In-Reply-To: <17721-a660b93948b165a7@postgresql.org>
References: <17721-a660b93948b165a7@postgresql.org>
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
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, nh.dev@sturdy.ai, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17721: A completely unused CTE negatively affect Query Plan
In-Reply-To: <2784036.1671042328@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