From 8666e5b03b4a5bbef6f64281b0ce67996a3cd26d Mon Sep 17 00:00:00 2001 From: wjhuang2016 Date: Thu, 13 Aug 2020 17:24:55 +0800 Subject: [PATCH] done Signed-off-by: wjhuang2016 --- planner/core/task.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/planner/core/task.go b/planner/core/task.go index 9aa2a0c951b40..3ec6866098100 100644 --- a/planner/core/task.go +++ b/planner/core/task.go @@ -711,14 +711,6 @@ func finishCopTask(ctx sessionctx.Context, task task) task { if !ok { return task } - if t.tablePlan != nil { - tp := t.tablePlan - for len(tp.Children()) > 0 { - tp = tp.Children()[0] - } - ts := tp.(*PhysicalTableScan) - ts.Columns = ExpandVirtualColumn(ts.Columns, ts.schema, ts.Table.Columns) - } sessVars := ctx.GetSessionVars() // copTasks are run in parallel, to make the estimated cost closer to execution time, we amortize // the cost to cop iterator workers. According to `CopClient::Send`, the concurrency @@ -729,6 +721,18 @@ func finishCopTask(ctx sessionctx.Context, task task) task { // Network cost of transferring rows of table scan to TiDB. if t.tablePlan != nil { t.cst += t.count() * sessVars.NetworkFactor * t.tblColHists.GetAvgRowSize(ctx, t.tablePlan.Schema().Columns, false, false) + + tp := t.tablePlan + for len(tp.Children()) > 0 { + if len(tp.Children()) == 1 { + tp = tp.Children()[0] + } else { + join := tp.(*PhysicalBroadCastJoin) + tp = join.children[1-join.InnerChildIdx] + } + } + ts := tp.(*PhysicalTableScan) + ts.Columns = ExpandVirtualColumn(ts.Columns, ts.schema, ts.Table.Columns) } t.cst /= copIterWorkers newTask := &rootTask{