fix: count each probe row once in HashJoinExec probe_hit_rate and avg_fanout - #25272
Merged
jayzhan211 merged 1 commit intoSep 15, 2026
Conversation
…_fanout - `probe_hit_rate` added the batch's row count to its total on every chunk. - A probe row whose matches span a chunk boundary was counted in both chunks, inflating the `probe_hit_rate` part and the `avg_fanout` total. `ProcessProbeBatchState` now tracks the last counted probe index.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25272 +/- ##
==========================================
- Coverage 81.89% 81.89% -0.01%
==========================================
Files 1133 1133
Lines 424660 424685 +25
Branches 424660 424685 +25
==========================================
+ Hits 347765 347781 +16
- Misses 56283 56290 +7
- Partials 20612 20614 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Hi @jayzhan211 , could you PTAL when you have a chance. Thanks! 🙏 |
jayzhan211
approved these changes
Sep 15, 2026
jayzhan211
left a comment
Contributor
There was a problem hiding this comment.
Thanks @CuteChuanChuan LGTM!
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 15, 2026
CuteChuanChuan
deleted the
issue-25077/hashjoinexect-metric-overcounts
branch
September 15, 2026 14:56
This was referenced Sep 15, 2026
Contributor
Author
|
Hi @jayzhan211 , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
probe_hit_ratemetric overcounts probe rows when a probe batch is processed in several chunks #25077 .Rationale for this change
EXPLAIN ANALYZEreportsprobe_hit_rateandavg_fanoutofHashJoinExectoo low whenever a probe batch produces more thanbatch_sizeoutput rows, e.g. when the build side has many duplicate keys. Both metrics are defined per probe row, but their counters were updated once per output chunk.What changes are included in this PR?
probe_hit_ratetotal: added only on the first chunk of each probe batch (state.offset == (0, None)), the same first-chunk check thatprocess_probe_batchalready uses for correlated null-awareLeftMark.probe_hit_ratepart andavg_fanouttotal: a newProcessProbeBatchState::matched_probe_idxrecords the last probe index counted so far.count_new_matched_probe_rowsdoes not count a chunk's first index again if it equals that value. Empty chunks leave it unchanged.joined_probe_idxis tracked after the join filter, while these metrics are defined before it, and the lookupoffsetcan point at a probe row that has not been counted yet.What is the testing strategy for this PR?
Two new tests in
hash_join/exec.rs, each run overhash_join_exec_configs(batch sizes 8192/10/5/2/1, perfect hash join on and off):join_probe_metrics_count_each_probe_row_once: duplicate build keys, so one probe row's matches are split across chunks. Fails without this change for batch sizes 5, 2 and 1.join_probe_metrics_count_probe_row_starting_new_chunk: unique build keys, so chunks split between probe rows. It guards against deduplicating by the lookup offset: comparing againstoffset.0(on non-first chunks) instead makes this test fail for batch sizes 2 and 1, while the first test still passes.Are there any user-facing changes?
probe_hit_rateandavg_fanoutshown byEXPLAIN ANALYZEare now correct when a probe batch is processed in several chunks. No public API changes.