pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: Jian Guo <gjian@vmware.com>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Hans Buschmann <buschmann@nidsa.net>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Cc: Zhenghua Lyu <zlyu@vmware.com>
Subject: Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500
Date: Mon, 08 Jan 2024 11:51:22 -0500
Message-ID: <1941515.1704732682@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMbWs49cnL7OcSfiyJ_VEKSYE1L5X7KjhOtVzSmkSauE89pLPQ@mail.gmail.com>
References: <4504e67078d648cdac3651b2960da6e7@nidsa.net>
	<SN6PR05MB5199BB4BB8C982BB519B6660C417A@SN6PR05MB5199.namprd05.prod.outlook.com>
	<46a7d950-7ca7-8ab9-76dd-f0bc7611c609@enterprisedb.com>
	<SN6PR05MB5199C0095508555B7D8D0D23C41EA@SN6PR05MB5199.namprd05.prod.outlook.com>
	<891440.1699483495@sss.pgh.pa.us>
	<CAMbWs4-W_81Q3ff1Bk3NU_ChRzOJK0njAoJanW-kXnPF0wjd1Q@mail.gmail.com>
	<414317.1700158568@sss.pgh.pa.us>
	<CAMbWs48Z_PvveOeankGA69=V=fqogusRKGVPBUGfYC0zDo1WPA@mail.gmail.com>
	<482957.1700192299@sss.pgh.pa.us>
	<CAMbWs49eVQMgfR-KNALJB15RR5r-zjNtNWnB0j5S=j40gtu1Jg@mail.gmail.com>
	<754093.1700250120@sss.pgh.pa.us>
	<608a4886-6c60-0f9e-97d5-591256bd4150@gmail.com>
	<1450797.1704580874@sss.pgh.pa.us>
	<CAMbWs49cnL7OcSfiyJ_VEKSYE1L5X7KjhOtVzSmkSauE89pLPQ@mail.gmail.com>

Richard Guo <guofenglinux@gmail.com> writes:
> On Sun, Jan 7, 2024 at 6:41 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Thanks for the report!  I guess we need something like the attached.

> +1.

Pushed, thanks for looking at it.

>> I'm surprised that this hasn't been noticed before; was the case
>> really unreachable before?

> It seems that this case is only reachable with Vars of an INSERT target
> relation, and it seems that there is no other way to reference such a
> Var other than using CTE.

I'm a little uncomfortable with that conclusion, but for the moment
I refrained from back-patching.  We can always add the patch to v16
later if we find it's not so unreachable.  (Before v16, there was
no find_base_rel here at all.)

			regards, tom lane





view thread (29+ messages)  latest in thread

Message-ID: <1941515.1704732682@sss.pgh.pa.us>
Permalink:  ../1941515.1704732682@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1941515.1704732682@sss.pgh.pa.us

 · 

reply

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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, guofenglinux@gmail.com, exclusion@gmail.com, gjian@vmware.com, tomas.vondra@enterprisedb.com, buschmann@nidsa.net, pgsql-hackers@lists.postgresql.org, zlyu@vmware.com
  Subject: Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500
  In-Reply-To: <1941515.1704732682@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