Skip to content

Commit

Permalink
Revert "planner: fix the wrong cost formula of MPPExchanger" (#35707)
Browse files Browse the repository at this point in the history
ref #35240
  • Loading branch information
qw4990 authored Jun 24, 2022
1 parent d0c1d1f commit 3f8df8c
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 183 deletions.
2 changes: 1 addition & 1 deletion executor/tiflashtest/tiflash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func TestMppExecution(t *testing.T) {
require.NoError(t, err)
ts := txn.StartTS()
taskID := tk.Session().GetSessionVars().AllocMPPTaskID(ts)
require.Equal(t, int64(5), taskID)
require.Equal(t, int64(6), taskID)
tk.MustExec("commit")
taskID = tk.Session().GetSessionVars().AllocMPPTaskID(ts + 1)
require.Equal(t, int64(1), taskID)
Expand Down
6 changes: 3 additions & 3 deletions planner/core/plan_cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,9 @@ func (p *PhysicalExchangeReceiver) GetPlanCost(taskType property.TaskType, costF
return 0, err
}
p.planCost = childCost
// accumulate net cost: rows * row-size * net-factor
rowSize := getTblStats(p.children[0]).GetAvgRowSize(p.ctx, p.children[0].Schema().Columns, false, false)
p.planCost += getCardinality(p.children[0], costFlag) * rowSize * p.ctx.GetSessionVars().GetNetworkFactor(nil)
// accumulate net cost
// TODO: this formula is wrong since it doesn't consider tableRowSize, fix it later
p.planCost += getCardinality(p.children[0], costFlag) * p.ctx.GetSessionVars().GetNetworkFactor(nil)
p.planCostInit = true
return p.planCost, nil
}
Expand Down
3 changes: 1 addition & 2 deletions planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -2070,8 +2070,7 @@ func (t *mppTask) enforceExchangerImpl(prop *property.PhysicalProperty) *mppTask
sender.SetChildren(t.p)
receiver := PhysicalExchangeReceiver{}.Init(ctx, t.p.statsInfo())
receiver.SetChildren(sender)
rowSize := getTblStats(sender.children[0]).GetAvgRowSize(sender.ctx, sender.children[0].Schema().Columns, false, false)
cst := t.cst + t.count()*rowSize*ctx.GetSessionVars().GetNetworkFactor(nil)
cst := t.cst + t.count()*ctx.GetSessionVars().GetNetworkFactor(nil)
sender.cost = cst
receiver.cost = cst
return &mppTask{
Expand Down
Loading

0 comments on commit 3f8df8c

Please sign in to comment.