From 14b03a48744bbb4e59c85b33ef76e10e35a5def5 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 14 Sep 2026 12:00:31 -0700 Subject: [PATCH] Skip probe-to-build SIP when probe >= build: avoid useless probe materialization --- src/optimizer/acc_hash_join_optimizer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/optimizer/acc_hash_join_optimizer.cpp b/src/optimizer/acc_hash_join_optimizer.cpp index c645d5f2e..41c3f5971 100644 --- a/src/optimizer/acc_hash_join_optimizer.cpp +++ b/src/optimizer/acc_hash_join_optimizer.cpp @@ -396,6 +396,16 @@ static bool tryProbeToBuildHJSIP(LogicalOperator* op, if (!isProbeSideQualified(op->getChild(0).get())) { return false; } + // Probe-to-build SIP materializes and rescans the whole probe side (ACCUMULATE + + // READ_FTABLE, one morsel per factorized-table row) to seed the build-side semi mask. + // When the probe side is at least as large as the build side, the mask can prune at most + // buildCard rows while materialization pays collect + rescan over probeCard rows, so the + // optimization cannot pay off: keep the plain pipelined hash join. Exempt the LIMIT + // pushdown path (probeLimit), whose capped probe still benefits from the mask. + if (probeLimit == nullptr && + hashJoin.getChild(0)->getCardinality() >= hashJoin.getChild(1)->getCardinality()) { + return false; + } auto probeRoot = hashJoin.getChild(0); auto buildRoot = hashJoin.getChild(1); auto hasSemiMaskApplied = false;