Re: remove_useless_joins vs. bug #19560

From: Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thom Brown <thom(at)linux(dot)com>, Richard Guo <guofenglinux(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: remove_useless_joins vs. bug #19560
Date: 2026-07-26 04:23:00
Message-ID: CA+COZaAVP6yHvSw6SQt6tieDhXCdDCK7qXTQP4fpiF4hsnVAPg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

These patches fix all my known failure cases (attached.) In addition, as a
plus, a small set of queries that previously didn't compile are now
accepted, for example:

SELECT coalesce(u1.id + 1, 1) AS o0
FROM (u AS u1 FULL JOIN (u AS u2 JOIN u AS u3 ON u2.id = u3.id)
ON u2.id = u2.id)
GROUP BY 1;

... previously gave ERROR: FULL JOIN is only supported with merge-joinable
or hash-joinable join conditions

now returns 10 rows (`2 … 11`), which I believe is correct.

```
HashAggregate
Group Key: COALESCE((u1.id + 1), 1)
-> Merge Full Join
-> Seq Scan on u u1
-> Materialize
-> Seq Scan on u u3
```

So that's nice.

On Sat, Jul 25, 2026 at 7:15 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Here's a patchset addressing that. 0001-0003 are the same as before,
> and then 0004 fixes this bug and adds tests.
>
> Your Claude session mentioned a different failure scenario, but
> gave no examples so I'm not quite sure if this covers it or not.
>
> regards, tom lane
>
>

Attachment Content-Type Size
finding-81-queries.sql application/sql 9.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Brazeal 2026-07-26 04:27:53 Re: remove_useless_joins vs. bug #19560
Previous Message Chengpeng Yan 2026-07-26 03:15:56 Re: Extended statistics improvement: multi-column MCV missing values