From 353cdc2673c2bed852d81989fc932028d25b0685 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Fri, 24 Jun 2022 16:39:13 +0800 Subject: [PATCH] fixup --- planner/core/plan_cost.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/planner/core/plan_cost.go b/planner/core/plan_cost.go index 5612933b9cf9b..73758b562536a 100644 --- a/planner/core/plan_cost.go +++ b/planner/core/plan_cost.go @@ -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 }