Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: remove old useless interfaces about cost model #37801

Merged
merged 11 commits into from Sep 15, 2022
6 changes: 4 additions & 2 deletions executor/set_test.go
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
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 {
qw4990 marked this conversation as resolved.
Show resolved Hide resolved
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
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