pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Simplify restriction matching in self-join elimination.
3+ messages / 1 participants
[nested] [flat]

* pgsql: Simplify restriction matching in self-join elimination.
@ 2026-10-15 16:43 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2026-10-15 16:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAHewXNmwYrp0DTuisCyfXXjVa_irUdDFApUzLVDg3J4MAR6gEg@mail.gmail.com
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8f2b598b4bc562d9609a47a3e069a5431237c85e

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 48 ++++++++-----------------------
1 file changed, 12 insertions(+), 36 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Simplify restriction matching in self-join elimination.
@ 2026-10-15 16:43 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2026-10-15 16:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Simplify restriction matching in self-join elimination.
@ 2026-10-15 16:43 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2026-10-15 16:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAHewXNmwYrp0DTuisCyfXXjVa_irUdDFApUzLVDg3J4MAR6gEg@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/10b2d9986b958b413d169b30ea43ae32a405bc72

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 48 ++++++++-----------------------
1 file changed, 12 insertions(+), 36 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-10-15 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 16:43 pgsql: Simplify restriction matching in self-join elimination. Tom Lane <tgl@sss.pgh.pa.us>
2026-10-15 16:43 pgsql: Simplify restriction matching in self-join elimination. Tom Lane <tgl@sss.pgh.pa.us>
2026-10-15 16:43 pgsql: Simplify restriction matching in self-join elimination. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox