Skip to content

Commit d77243e

Browse files
planner: disable tiflash late materialization when fast scan is enable (#42683)
close #40601
1 parent 2af85d1 commit d77243e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

planner/core/optimizer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,13 @@ func prunePhysicalColumnsInternal(sctx sessionctx.Context, plan PhysicalPlan) er
555555
// - Filter conditions that apply to the same column are either pushed down or not pushed down at all.
556556
func tryEnableLateMaterialization(sctx sessionctx.Context, plan PhysicalPlan) {
557557
// check if EnableLateMaterialization is set
558-
if sctx.GetSessionVars().EnableLateMaterialization {
558+
if sctx.GetSessionVars().EnableLateMaterialization && !sctx.GetSessionVars().TiFlashFastScan {
559559
predicatePushDownToTableScan(sctx, plan)
560560
}
561+
if sctx.GetSessionVars().EnableLateMaterialization && sctx.GetSessionVars().TiFlashFastScan {
562+
sc := sctx.GetSessionVars().StmtCtx
563+
sc.AppendWarning(errors.New("FastScan is not compatible with late materialization, late materialization is disabled"))
564+
}
561565
}
562566

563567
/*

planner/core/tiflash_selection_late_materialization.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ func withHeavyCostFunctionForTiFlashPrefetch(cond expression.Expression) bool {
178178
return true
179179
case ast.StrToDate, ast.SubDate, ast.SubTime, ast.TimeLiteral, ast.TimeFormat, ast.TimeToSec, ast.TimeDiff, ast.TimestampDiff:
180180
return true
181+
// regexp functions
182+
case ast.Regexp, ast.RegexpLike, ast.RegexpReplace, ast.RegexpSubstr, ast.RegexpInStr:
183+
return true
181184
// TODO: add more heavy cost functions
182185
}
183186
}
@@ -203,7 +206,7 @@ func removeSpecificExprsFromSelection(physicalSelection *PhysicalSelection, expr
203206
// @param: physicalTableScan: the PhysicalTableScan to be pushed down to
204207
func predicatePushDownToTableScanImpl(sctx sessionctx.Context, physicalSelection *PhysicalSelection, physicalTableScan *PhysicalTableScan) {
205208
// When the table is small, there is no need to push down the conditions.
206-
if physicalTableScan.tblColHists.RealtimeCount <= tiflashDataPackSize {
209+
if physicalTableScan.tblColHists.RealtimeCount <= tiflashDataPackSize || physicalTableScan.KeepOrder {
207210
return
208211
}
209212
conds := physicalSelection.Conditions

0 commit comments

Comments
 (0)