| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Simplify restriction matching in self-join elimination. |
| Date: | 2026-10-15 16:43:01 |
| Message-ID: | E1xHOXl-00000001l1f-2kb0@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Simplify restriction matching in self-join elimination.
In match_unique_clauses(), use equal() to compare complete restriction
clauses after substituting the relation ID, instead of comparing their
operands separately. This ensures that the operator and input
collation also match, preventing incorrect self-join elimination when
restrictions have identical operands but different semantics.
The former code apparently intended to support matching clauses to
commuted versions of those clauses, but the amount of complication
that added seems far out of proportion to the value, so just drop
that goal. (If we wanted to reinstate it, something based on
applying CommuteOpExpr or equivalent logic would be better.)
Author: Tender Wang <tndrwang(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAHewXNmwYrp0DTuisCyfXXjVa_irUdDFApUzLVDg3J4MAR6gEg@mail.gmail.com
Backpatch-through: 18
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/86ce68d9e6f5ef246aab3af424fb2dab16b53a68
Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 48 ++++++++-----------------------
1 file changed, 12 insertions(+), 36 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Masahiko Sawada | 2026-10-15 17:33:56 | pgsql: Fix DROP DATABASE FORCE failing on parallel autovacuum workers. |
| Previous Message | Peter Geoghegan | 2026-10-15 16:18:37 | pgsql: Fix _bt_readnextpage half-dead leftmost page assert. |