Re: Performance issue in foreign-key-aware join estimation

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Subject: Re: Performance issue in foreign-key-aware join estimation
Date: 2019-07-21 22:35:27
Message-ID: CAKJS1f_FrzaS4zWBHj_q6kxMFny+tjtBGo6Et=uJ7sZP6RcRAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 22 Jul 2019 at 01:50, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> wrote:
>
> On Mon, 22 Jul 2019 at 00:44, Andreas Seltenreich <seltenreich(at)gmx(dot)de> wrote:
> > sqlsmith triggers an assertion in this commit (3373c7155350):
> >
> > TRAP: FailedAssertion("!(rel->reloptkind == RELOPT_BASEREL)", File: "equivclass.c", Line: 764)
>
> Thanks for the report.
>
> It looks like this is caused by the join removal code removing the
> LEFT JOIN and leaving a dead rel in the eclasses ec_relids. The fix
> is likely either to adjust the Assert to allow that or to add an if
> test so that we only bother calling bms_add_member for base rels. I'm
> not quite sure yet.

I ended up adjusting the Assert to allow dead rels too. I thought
about adding an if test so we only do the bms_add_member for base
rels, but I didn't really like the special case where eclass_indexes
wouldn't be correctly set for dead rels. I had thoughts that dead rels
were not common enough to go to additional trouble over. That's
debatable of course. I also thought about removing the Assert
completely, but it does help verify we don't get anything unexpected
in ec_relids.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Where is Where 2019-07-21 23:28:50 Re: new function for tsquery creartion
Previous Message Tom Lane 2019-07-21 21:54:17 Re: The flinfo->fn_extra question, from me this time.