planner: not use DescScanFactor when rows is less than smallScanThreshold for compatibility (#36263)
This commit is contained in:
@ -2198,6 +2198,7 @@ func (ds *DataSource) getOriginalPhysicalTableScan(prop *property.PhysicalProper
|
||||
HandleCols: ds.handleCols,
|
||||
tblCols: ds.TblCols,
|
||||
tblColHists: ds.TblColHists,
|
||||
prop: prop,
|
||||
}.Init(ds.ctx, ds.blockOffset)
|
||||
ts.filterCondition = make([]expression.Expression, len(path.TableFilters))
|
||||
copy(ts.filterCondition, path.TableFilters)
|
||||
@ -2267,6 +2268,7 @@ func (ds *DataSource) getOriginalPhysicalIndexScan(prop *property.PhysicalProper
|
||||
physicalTableID: ds.physicalTableID,
|
||||
tblColHists: ds.TblColHists,
|
||||
pkIsHandleCol: ds.getPKIsHandleCol(),
|
||||
prop: prop,
|
||||
}.Init(ds.ctx, ds.blockOffset)
|
||||
statsTbl := ds.statisticTable
|
||||
if statsTbl.Indices[idx.ID] != nil {
|
||||
|
||||
@ -468,6 +468,7 @@ type PhysicalIndexScan struct {
|
||||
// tblColHists contains all columns before pruning, which are used to calculate row-size
|
||||
tblColHists *statistics.HistColl
|
||||
pkIsHandleCol *expression.Column
|
||||
prop *property.PhysicalProperty
|
||||
}
|
||||
|
||||
// Clone implements PhysicalPlan interface.
|
||||
@ -569,6 +570,7 @@ type PhysicalTableScan struct {
|
||||
// tblCols and tblColHists contains all columns before pruning, which are used to calculate row-size
|
||||
tblCols []*expression.Column
|
||||
tblColHists *statistics.HistColl
|
||||
prop *property.PhysicalProperty
|
||||
}
|
||||
|
||||
// Clone implements PhysicalPlan interface.
|
||||
|
||||
@ -404,7 +404,7 @@ func (p *PhysicalTableScan) GetPlanCost(taskType property.TaskType, costFlag uin
|
||||
switch p.ctx.GetSessionVars().CostModelVersion {
|
||||
case modelVer1: // scan cost: rows * row-size * scan-factor
|
||||
scanFactor := p.ctx.GetSessionVars().GetScanFactor(p.Table)
|
||||
if p.Desc {
|
||||
if p.Desc && p.prop != nil && p.prop.ExpectedCnt >= smallScanThreshold {
|
||||
scanFactor = p.ctx.GetSessionVars().GetDescScanFactor(p.Table)
|
||||
}
|
||||
selfCost = getCardinality(p, costFlag) * p.getScanRowSize() * scanFactor
|
||||
@ -441,7 +441,7 @@ func (p *PhysicalIndexScan) GetPlanCost(taskType property.TaskType, costFlag uin
|
||||
switch p.ctx.GetSessionVars().CostModelVersion {
|
||||
case modelVer1: // scan cost: rows * row-size * scan-factor
|
||||
scanFactor := p.ctx.GetSessionVars().GetScanFactor(p.Table)
|
||||
if p.Desc {
|
||||
if p.Desc && p.prop != nil && p.prop.ExpectedCnt >= smallScanThreshold {
|
||||
scanFactor = p.ctx.GetSessionVars().GetDescScanFactor(p.Table)
|
||||
}
|
||||
selfCost = getCardinality(p, costFlag) * p.getScanRowSize() * scanFactor
|
||||
|
||||
Reference in New Issue
Block a user