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