Extending Self-Join Elimination to partitioned tables

From: Trương Hoàng Quân <truonghoangquan456(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Subject: Extending Self-Join Elimination to partitioned tables
Date: 2026-07-10 23:44:32
Message-ID: CAGJgb9u9jzXX7fOv5Uc0BfbmrVtTcsSRhG1T+UUWLhcwruDi5A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Please find attached a patch that extends Self-Join Elimination to
partitioned tables. The original SJE commit called this out as future
work, since eliminating redundant self-joins before partition expansion
can be a significant win.

This patch is mostly tests at this point. So far the behavior looks
correct to me and I haven't found any cases where it produces a wrong
plan or wrong results, so I've focused on building out regression tests
covering the cases I could come up with.

I'd appreciate any feedback. If anyone has objections, or can think of a
query pattern where this would break (wrong results, crashes, planner
assertions), please let me know. In the meantime I'll keep expanding the
test coverage for the corner cases I can think of.

Regards,
Quan Truong

Attachment Content-Type Size
v1-0001-Add-correctness-test-for-partition-table-sje.patch text/x-patch 22.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2026-07-11 02:42:34 Re: postgres_fdw could deparse ArrayCoerceExpr
Previous Message Peter Geoghegan 2026-07-10 23:20:54 Re: Reduce cleanup lock contention on standby replay