Skip to content

Commit

Permalink
planner: remove old useless interfaces about cost model (#37801)
Browse files Browse the repository at this point in the history
ref #35240
  • Loading branch information
qw4990 authored Sep 15, 2022
1 parent e9a8577 commit b5ab19c
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 1,299 deletions.
6 changes: 4 additions & 2 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,11 @@ func TestSetVar(t *testing.T) {
// test for tidb_enable_new_cost_interface
tk.MustQuery("select @@global.tidb_enable_new_cost_interface").Check(testkit.Rows("1")) // default value is 1
tk.MustExec("set global tidb_enable_new_cost_interface=0")
tk.MustQuery("select @@global.tidb_enable_new_cost_interface").Check(testkit.Rows("0"))
tk.MustExec("set global tidb_enable_new_cost_interface=1")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1287 'OFF' is deprecated and will be removed in a future release. Please use ON instead"))
tk.MustQuery("select @@global.tidb_enable_new_cost_interface").Check(testkit.Rows("1"))
tk.MustExec("set tidb_enable_new_cost_interface=0")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1287 'OFF' is deprecated and will be removed in a future release. Please use ON instead"))
tk.MustQuery("select @@session.tidb_enable_new_cost_interface").Check(testkit.Rows("1"))

// test for tidb_remove_orderby_in_subquery
tk.MustQuery("select @@session.tidb_remove_orderby_in_subquery").Check(testkit.Rows("0")) // default value is 0
Expand Down
14 changes: 3 additions & 11 deletions planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,8 @@ func (e *Explain) getOperatorInfo(p Plan, id string) (string, string, string, st
}
estCost := "N/A"
if pp, ok := p.(PhysicalPlan); ok {
if p.SCtx().GetSessionVars().EnableNewCostInterface {
planCost, _ := pp.GetPlanCost(property.RootTaskType, NewDefaultPlanCostOption())
estCost = strconv.FormatFloat(planCost, 'f', 2, 64)
} else {
estCost = strconv.FormatFloat(pp.Cost(), 'f', 2, 64)
}
planCost, _ := pp.GetPlanCost(property.RootTaskType, NewDefaultPlanCostOption())
estCost = strconv.FormatFloat(planCost, 'f', 2, 64)
}
var accessObject, operatorInfo string
if plan, ok := p.(dataAccesser); ok {
Expand Down Expand Up @@ -853,11 +849,7 @@ func binaryOpFromFlatOp(explainCtx sessionctx.Context, op *FlatOperator, out *ti
}
if op.IsPhysicalPlan {
p := op.Origin.(PhysicalPlan)
if p.SCtx().GetSessionVars().EnableNewCostInterface {
out.Cost, _ = p.GetPlanCost(property.RootTaskType, NewDefaultPlanCostOption())
} else {
out.Cost = p.Cost()
}
out.Cost, _ = p.GetPlanCost(property.RootTaskType, NewDefaultPlanCostOption())
}
if rootStats != nil {
basic, groups := rootStats.MergeStats()
Expand Down
6 changes: 0 additions & 6 deletions planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,12 +1006,9 @@ func (p *LogicalJoin) constructInnerTableScanTask(
StatsVersion: ds.stats.StatsVersion,
// NDV would not be used in cost computation of IndexJoin, set leave it as default nil.
}
rowSize := ts.getScanRowSize()
sessVars := ds.ctx.GetSessionVars()
copTask := &copTask{
tablePlan: ts,
indexPlanFinished: true,
cst: sessVars.GetScanFactor(ts.Table) * rowSize * ts.stats.RowCount,
tblColHists: ds.TblColHists,
keepOrder: ts.KeepOrder,
}
Expand Down Expand Up @@ -1178,9 +1175,6 @@ func (p *LogicalJoin) constructInnerIndexScanTask(
tmpPath.CountAfterAccess = cnt
}
is.stats = ds.tableStats.ScaleByExpectCnt(tmpPath.CountAfterAccess)
rowSize := is.getScanRowSize()
sessVars := ds.ctx.GetSessionVars()
cop.cst = tmpPath.CountAfterAccess * rowSize * sessVars.GetScanFactor(ds.tableInfo)
finalStats := ds.tableStats.ScaleByExpectCnt(rowCount)
is.addPushedDownSelection(cop, ds, tmpPath, finalStats)
t := cop.convertToRootTask(ds.ctx)
Expand Down
Loading

0 comments on commit b5ab19c

Please sign in to comment.