Skip to content

Commit 3cf71e8

Browse files
committed
opt: use optimizer_span_limit in split-scan rules
Use the optimizer_span_limit session setting as an additional upper bound in splitScanIntoUnionScansOrSelects. When set, the span limit caps the hard maximum scan count, preventing the split-scan rules (SplitLimitedScanIntoUnionScans, SplitLimitedSelectIntoUnionSelects, SplitGroupByScanIntoUnionScans, etc.) from generating more union branches than the limit allows. Release note: None
1 parent 25b3b11 commit 3cf71e8

3 files changed

Lines changed: 865 additions & 0 deletions

File tree

pkg/sql/opt/xform/general_funcs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ func (c *CustomFuncs) splitScanIntoUnionScansOrSelects(
268268
// If OptSplitScanLimit is below maxScanCount, we will decrease maxScanCount
269269
// to that value because a hard limit should never be lower than a soft limit.
270270
hardMaxScanCount := int(c.e.evalCtx.SessionData().OptSplitScanLimit)
271+
if spanLimit := int(c.e.evalCtx.SessionData().OptimizerSpanLimit); spanLimit > 0 && spanLimit < hardMaxScanCount {
272+
hardMaxScanCount = spanLimit
273+
}
271274
if hardMaxScanCount < maxScanCount {
272275
maxScanCount = hardMaxScanCount
273276
}

0 commit comments

Comments
 (0)