@@ -400,6 +400,7 @@ func (is *PhysicalIndexScan) addPushedDownSelection(copTask *copTask, p *DataSou
400
400
// Add filter condition to table plan now.
401
401
indexConds , tableConds := path .indexFilters , path .tableFilters
402
402
if indexConds != nil {
403
+ copTask .cst += copTask .count () * cpuFactor
403
404
count := path .countAfterAccess
404
405
if count >= 1.0 {
405
406
selectivity := path .countAfterIndex / path .countAfterAccess
@@ -409,14 +410,13 @@ func (is *PhysicalIndexScan) addPushedDownSelection(copTask *copTask, p *DataSou
409
410
indexSel := PhysicalSelection {Conditions : indexConds }.init (is .ctx , stats )
410
411
indexSel .SetChildren (is )
411
412
copTask .indexPlan = indexSel
412
- copTask .cst += copTask .count () * cpuFactor
413
413
}
414
414
if tableConds != nil {
415
415
copTask .finishIndexPlan ()
416
+ copTask .cst += copTask .count () * cpuFactor
416
417
tableSel := PhysicalSelection {Conditions : tableConds }.init (is .ctx , p .statsAfterSelect .scaleByExpectCnt (expectedCnt ))
417
418
tableSel .SetChildren (copTask .tablePlan )
418
419
copTask .tablePlan = tableSel
419
- copTask .cst += copTask .count () * cpuFactor
420
420
}
421
421
}
422
422
@@ -568,10 +568,9 @@ func (ds *DataSource) convertToTableScan(prop *requiredProp, path *accessPath) (
568
568
func (ts * PhysicalTableScan ) addPushedDownSelection (copTask * copTask , stats * statsInfo ) {
569
569
// Add filter condition to table plan now.
570
570
if len (ts .filterCondition ) > 0 {
571
+ copTask .cst += copTask .count () * cpuFactor
571
572
sel := PhysicalSelection {Conditions : ts .filterCondition }.init (ts .ctx , stats )
572
573
sel .SetChildren (ts )
573
574
copTask .tablePlan = sel
574
- // FIXME: It seems wrong...
575
- copTask .cst += copTask .count () * cpuFactor
576
575
}
577
576
}
0 commit comments