Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, Jian Guo <gjian(at)vmware(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Hans Buschmann <buschmann(at)nidsa(dot)net>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Zhenghua Lyu <zlyu(at)vmware(dot)com>
Subject: Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500
Date: 2023-11-17 03:45:44
Message-ID: CAKFQuwa-pA960B=Ev=6SSqzPv2Pu5BXgZC=J9wYfRB3-MJ1faQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thursday, November 16, 2023, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

>
> That line of argument also leads to the conclusion that it'd be
> okay to expose info about the ordering of the CTE result to the
> upper planner. This patch doesn't do that, and I'm not sufficiently
> excited about the issue to go write some code. But if someone else
> does, I think we shouldn't exclude doing it on the grounds of wanting
> to preserve an optimization fence. The fence is sort of one-way
> in this line of thinking: information can propagate up to the outer
> planner level, but not down into the CTE plan.
>

This is indeed my understanding of what materialized means. Basically, the
CTE is done first and in isolation; but any knowledge of its result shape
can be used when referencing it.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2023-11-17 03:53:31 Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500
Previous Message Tom Lane 2023-11-17 03:38:19 Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500