Batch-mode subtree elapsed sums when computing parent self-time (#215 D1)#268
Merged
erikdarlingdata merged 1 commit intodevfrom Apr 24, 2026
Merged
Conversation
…f-time (#215 D1) Joe's plan 5GQmlu6m7W has a Parallelism (Gather Streams) above a batch-mode zone of three operators: Compute Scalar (9ms) / Hash Match Aggregate (10,294ms) / Clustered Index Scan (13,761ms). The exchange itself has elapsed 21,177ms and was being reported with 21,168ms of self-time because GetEffectiveChildElapsedMs only subtracted the direct child (the 9ms Compute Scalar). Batch mode pipelines operators — each operator's elapsed is standalone wall time for that operator, not cumulative of descendants the way row mode is. So for a row-mode parent above a batch-mode subtree, the correct "effective child elapsed" is the sum across the whole batch pipeline, not just the direct child. New SumBatchSubtreeElapsedMs walks a contiguous batch-mode zone (stopping at Parallelism boundaries) and sums ActualElapsedMs. GetEffectiveChildElapsedMs now routes batch-mode children with actual stats through that helper. Result on 5GQmlu6m7W: Parallelism self-time goes from 21,168ms (~56% of statement) to 0ms (clamped — 21.177 - 24.064 is negative, matching Joe's math). No more bogus "Expensive Operator" warning on the gather-streams. Regression check: - c1-c5.sqlplan (serial row mode) — all warnings unchanged - 20260415_1.sqlplan (parallel batch-mode) — all wait benefits and operator warnings unchanged (the batch subtree rule only fires when computing self-time of a row-mode parent above a batch child) D2 (unhelpful CXPACKET warning) was already addressed by v1.7.7's WaitStatsKnowledge content strip — the CXPACKET item now shows only the raw wait ms/count, no speculative fix text. Joe's deeper concern about CXPACKET double-counting other waits is a separate future refinement. Version bump 1.7.7 -> 1.7.8. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Parallelism (Gather Streams) over a batch-mode zone was reporting bogus self-time because `GetEffectiveChildElapsedMs` only subtracted the direct child's elapsed. Batch-mode operators pipeline — each elapsed is standalone, not cumulative — so the correct subtraction sums across the batch pipeline.
Verified on Joe's plan 5GQmlu6m7W
Regression check
D2 note
Joe also flagged an unhelpful CXPACKET warning on the same plan. That was addressed by v1.7.7's WaitStatsKnowledge content strip; the CXPACKET item now shows raw ms/count only. The deeper concern about CXPACKET double-counting other waits is a future refinement.
Version 1.7.7 → 1.7.8.
🤖 Generated with Claude Code