You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NestedLoopJoinExec spill fallback evaluates the left input twice #24661
Repeated evaluation can duplicate expensive scans, network reads, or other work performed by the left subtree. It also increases pressure during an OOM recovery path.
This issue does not propose changing ExecutionPlan::execute semantics. Each call should continue producing an independent stream, as established by #21565. The goal is to avoid the redundant call where possible.
Proposed direction
Refactor the initial left-side collection so that, when its reservation cannot grow, the fallback can retain:
Already buffered batches.
The batch that encountered memory pressure.
The remaining original input stream.
The fallback could then spill or process that state directly instead of executing the left child again.
Alternative designs that guarantee a single left-side evaluation would also address the issue.
Testing
Add a test execution plan that:
Counts calls to execute().
Produces an independent stream on every call.
Is used as the left child of NestedLoopJoinExec.
Forces the memory-limited spill path.
Assert that:
The left child is executed exactly once.
Spill occurs.
The query returns the expected results.
Memory reservations and temporary spill files are released after completion or cancellation.
Activity