Re: Wrong results from self-join elimination with different restriction operators

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: Re: Wrong results from self-join elimination with different restriction operators
Date: 2026-10-15 03:13:07
Message-ID: CAHewXNkC5ttDBVmz4mKKPZ0chKJSpmDN2oE93sg16FKok5dS7w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 于2026年10月15日周四 04:56写道:
>
> If we're going to refuse that, I wonder if we couldn't simplify
> match_unique_clauses a great deal: just insist that the two OpExpr
> clauses be equal(), after the ChangeVarNodes substitution on the outer
> clause. Your proposal already breaks commuted-clause cases, which
> seem like the only justification for all the futzing around with left
> and right operands. I doubt that detecting that is of any real-world
> value anyway.
>

Attached is v2, following your suggestion to compare the complete
clauses with equal() after the ChangeVarNodes substitution. I also
removed the test added in v1.

I ran the regression tests and found no plan differences. This
suggests the existing tests don't cover cases where matching commuted
restrictions enables self-join elimination.

--
Thanks,
Tender Wang

Attachment Content-Type Size
v2-0001-Simplify-restriction-matching-in-self-join-elimin.patch text/plain 3.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-10-15 03:15:47 Re: Parallel autovacuum: honor reduced parallel workers after heap scan phase
Previous Message shihao zhong 2026-10-15 02:48:17 Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding