Skip to content

Commit

Permalink
planner: fix the wrong cost formula of MPPExchanger on cost model ver2 (
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 authored Jun 27, 2022
1 parent 31c92c6 commit ab27d49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions planner/core/plan_cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,12 @@ func (p *PhysicalExchangeReceiver) GetPlanCost(taskType property.TaskType, costF
}
p.planCost = childCost
// 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)
if p.ctx.GetSessionVars().CostModelVersion == modelVer1 {
p.planCost += getCardinality(p.children[0], costFlag) * p.ctx.GetSessionVars().GetNetworkFactor(nil)
} else { // to avoid regression, only consider row-size on model ver2
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)
}
p.planCostInit = true
return p.planCost, nil
}
Expand Down

0 comments on commit ab27d49

Please sign in to comment.