Re: BUG #18429: Inconsistent results on similar queries with join lateral

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Benoit Ryder <b(dot)ryder(at)ateme(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18429: Inconsistent results on similar queries with join lateral
Date: 2024-04-12 15:50:02
Message-ID: 450117.1712937002@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Benoit Ryder <b(dot)ryder(at)ateme(dot)com> writes:
> Would you know a way to avoid this bug? I could probably tweak the query
> until the result is looking good, but I would prefer to make sure the
> bug won't reappear if the query is used with different data or context.

I'm not seeing a bulletproof way offhand, other than "update to v16".
Disabling nestloop plans fixes your Q4 in the back branches, but not
Q1 (because there's no opportunity for a hash or merge join in Q1).

It looks like the problem is that the old join_clause_is_movable
logic is incorrectly deciding that the WHERE condition can be
pushed down to the sub-select relation. So we should be able to
fix it there, but I'm not sure how messy that will be or whether
we'll lose the ability to generate some correct plans. It's hard
to justify putting a huge amount of work into old branches though.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-04-12 15:57:58 Re: BUG #18429: Inconsistent results on similar queries with join lateral
Previous Message Benoit Ryder 2024-04-12 15:33:41 Re: BUG #18429: Inconsistent results on similar queries with join lateral