Re: BUG #18170: Unexpected error: no relation entry for relid 3

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, Vik Fearing <vik(at)postgresfriends(dot)org>, zuming(dot)jiang(at)inf(dot)ethz(dot)ch, pgsql-bugs(at)lists(dot)postgresql(dot)org, Alexander Korotkov <akorotkov(at)postgresql(dot)org>
Subject: Re: BUG #18170: Unexpected error: no relation entry for relid 3
Date: 2023-11-01 22:29:41
Message-ID: CAPpHfdsnAbg8CaK+NJ8AkiG_+_Tt07eCStkb1LOa50f0UsT5RQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Nov 1, 2023 at 12:29 PM Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
> On Sat, Oct 28, 2023 at 12:12 AM Alexander Korotkov
> <aekorotkov(at)gmail(dot)com> wrote:
> >
> > On Fri, Oct 27, 2023 at 5:41 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > > Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> > > > Alternatively, can we look at subroot->parse->targetList instead of
> > > > subquery->targetList where we call estimate_num_groups on the output of
> > > > the subquery?
> > >
> > > Please read the comment just above that.
> >
> > Thank you, Tom, This is clear.
>
>
> Hmm... I just found that I wasn't attentive enough. The proposed
> change is to use subroot->parse->targetList, not
> subroot->processed_tlist. I don't know what could be the problem
> here.

My proposal is to use the attached patch as a hotfix for the bug considered.

And for future I propose to consider two questions (each should
probably go to its own thread):
1) Getting rid of having two distinct copies of parse tree (have one
copy instead).
2) Introduce relation aliases to simplify self-join removal.

Any thoughts?

------
Regards,
Alexander Korotkov

Attachment Content-Type Size
fix_estimate_num_groups_with_self_join_removal.patch application/octet-stream 3.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-11-01 23:02:21 BUG #18177: certain queries under certain contexts take multiple orders of magnitude longer compared to v10
Previous Message Tom Lane 2023-11-01 21:20:21 Re: BUG #17552: pg_stat_statements tracks internal FK check queries when COPY used to load data