[PATCH] Fix hash join costing when the inner side is provably unique

Started by He Kuang12 days ago2 messageshackers
Jump to latest
#1He Kuang
hekuang.git@gmail.com

Hi hackers,

Attached is a standalone fix for hash join costing when the inner side
is provably unique. compute_semi_anti_join_factors() asks
clauselist_selectivity() with the join's own SpecialJoinInfo, so
eqjoinsel() returns ordinary equality selectivity instead of the
semi-join selectivity; separately, an inner-unique plain inner join
should charge hashjointuples on the joinrel row estimate, not
outer_matched_rows. It follows db2d9932 (Richard Guo) but has no
dependency on any other patch, applies cleanly to master 13eb5640
(2026-11-13), and passes make check 243/243.

Comments welcome.

Attachments:

t259208_1
fix-hash-join-costing-inner-unique.patchtext/plain; charset=US-ASCII; name=fix-hash-join-costing-inner-unique.patchDownload+80-30
#2He Kuang
hekuang.git@gmail.com
In reply to: He Kuang (#1)
[PATCH v2] Fix hash join costing when the inner side is provably unique

Hi,

Attached is v2.

Changes since v1:
- Rebased onto master 11591f273e6a (2026-11-17).
- Update contrib/pg_plan_advice/expected/gather.out: the corrected
costing changes the plan recorded there from a parallel hash join to
a merge join. make check and check-world pass with the update.

The costing logic itself is unchanged.

Regards,
He Kuang

Attachments:

t259208_2
fix-hash-join-costing-inner-unique-v2.patchtext/plain; charset=US-ASCII; name=fix-hash-join-costing-inner-unique-v2.patchDownload+113-57