From: | David Gilman <davidgilman1(at)gmail(dot)com> |
---|---|
To: | Ron <ronljohnsonjr(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Query plan regression between CTE and views |
Date: | 2023-08-15 12:59:33 |
Message-ID: | CALBH9DBu65P-FZJ2JDR7W0ddH6CsjWn5yLKpTmi2xiRifo796Q@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm on PostgreSQL 15 with essentially a stock configuration.
On Tue, Aug 15, 2023 at 8:58 AM Ron <ronljohnsonjr(at)gmail(dot)com> wrote:
>
> On 8/14/23 09:54, David Gilman wrote:
> > I have a query that was originally written as a handful of CTEs out of
> > convenience. It is producing a reasonable query plan because the CTE
> > materialization was kicking in at an appropriate place. The CTEs
> > aren't totally linear. The graph looks like this, where A, B, C and D
> > are CTEs, and B -> A means B selects from A. In Graphviz format:
> >
> > G {
> > B -> A;
> > C -> A;
> > C -> B;
> > D -> C;
> > }
> >
> > Out of curiosity I tried turning the query into a series of views and
> > ran that query. The query plan is vastly different, there is no
> > materialization and it runs much slower.
> >
> > My question is: is this a valid bug? I am not sure if I should expect
> > the view version to find a way to materialize and produce a comparable
> > query plan. Also, making a minimal test case is going to take a bit
> > and I don't want to start unless this smells like a genuine bug.
>
>
> What version of Postgresql?
>
> (Also, back before, I think, v12, CTEs were optimizer fences. You were
> better using views or sub-queries.)
>
> --
> Born in Arizona, moved to Babylonia.
>
>
>
>
--
David Gilman
:DG<
From | Date | Subject | |
---|---|---|---|
Next Message | Erik Wienhold | 2023-08-15 14:27:46 | Re: AW: Cast INTEGER to BIT confusion |
Previous Message | [Quipsy] Markus Karg | 2023-08-15 12:02:21 | AW: Cast INTEGER to BIT confusion |