Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 committed Jul 15, 2022
1 parent 911e7cc commit 1bf3b3a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions planner/core/physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,11 @@ type PhysicalSelection struct {
basePhysicalPlan

Conditions []expression.Expression

// The flag indicates whether this Selection is from a DataSource.
// The flag is only used by cost model for compatibility and will be removed later.
// Please see https://github.com/pingcap/tidb/issues/36243 for more details.
fromDataSource bool
}

// Clone implements PhysicalPlan interface.
Expand Down
3 changes: 3 additions & 0 deletions planner/core/plan_cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (p *PhysicalSelection) GetPlanCost(taskType property.TaskType, costFlag uin
return 0, errors.Errorf("unknown task type %v", taskType)
}
selfCost = getCardinality(p.children[0], costFlag) * cpuFactor
if p.fromDataSource {
selfCost = 0 // for compatibility, see https://github.com/pingcap/tidb/issues/36243
}
case modelVer2: // selection cost: rows * num-filters * cpu-factor
var cpuFactor float64
switch taskType {
Expand Down
1 change: 1 addition & 0 deletions planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ func (t *copTask) handleRootTaskConds(ctx sessionctx.Context, newTask *rootTask)
selectivity = SelectionFactor
}
sel := PhysicalSelection{Conditions: t.rootTaskConds}.Init(ctx, newTask.p.statsInfo().Scale(selectivity), newTask.p.SelectBlockOffset())
sel.fromDataSource = true
sel.SetChildren(newTask.p)
newTask.p = sel
sel.cost = newTask.cost()
Expand Down

0 comments on commit 1bf3b3a

Please sign in to comment.