Apache Software Foundation / DataFusion
Merged upstreamCorrectnessMerged Sep 3, 2026

Exclude child compute from nested-loop join metrics

Corrected DataFusion's nested-loop join timing boundaries so plan-level elapsed-compute metrics remain additive across normal, memory-limited, spill, and replay execution paths.

apache/datafusion · #24491

Observability correctness fix

NestedLoopJoinExec now reports only join-owned compute time instead of double-counting work already measured by its child operators.

Problem

The join's build and probe timers started before polling their child streams. Because those child operators publish their own compute time, NestedLoopJoinExec included the same work again and overstated plan-level elapsed compute.

Approach

Moved join timing inside each ready child result so it covers only build-side materialization, join evaluation, and join-owned bookkeeping. Applied the same accounting boundaries to spill and unmatched-right replay paths.

Impact and scope

  • Makes operator metrics trustworthy for query profiling, bottleneck analysis, and performance regression work.
  • Prevents child execution time from being charged twice when users aggregate compute across a physical plan.
  • Keeps query results and public APIs unchanged while aligning standard and memory-limited execution metrics.

Validation

  • Added four timing regressions covering ordinary execution, spill behavior, and unmatched-right replay; restoring the old timer scopes made each regression fail.
  • Passed focused and full physical-plan tests, workspace CI-profile tests, and Clippy with warnings denied; all final commit checks succeeded.
  • The authored commits and GitHub-verified merge credit Goutam Adwant; a maintainer approved the normal and memory-limited coverage and thanked him for the contribution.