diff --git a/plan/gen_physical_plans.go b/plan/gen_physical_plans.go index 0fd15e6eacd5b..178f84254de37 100644 --- a/plan/gen_physical_plans.go +++ b/plan/gen_physical_plans.go @@ -385,8 +385,8 @@ func (p *LogicalJoin) tryToGetIndexJoin(prop *requiredProp) ([]PhysicalPlan, boo plans = append(plans, join...) } case InnerJoin: - lhsCardinality := p.Children()[0].statsInfo().Count() - rhsCardinality := p.Children()[1].statsInfo().Count() + lhsCardinality := p.Children()[0].StatsInfo().Count() + rhsCardinality := p.Children()[1].StatsInfo().Count() leftJoins := p.getIndexJoinByOuterIdx(prop, 0) if leftOuter && leftJoins != nil { diff --git a/plan/plan.go b/plan/plan.go index 84344be0f5417..9a256be8654b5 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -38,6 +38,9 @@ type Plan interface { replaceExprColumns(replace map[string]*expression.Column) context() sessionctx.Context + + // StatsInfo will return the statsInfo for this plan. + StatsInfo() *statsInfo } // taskType is the type of execution task. @@ -205,9 +208,6 @@ type PhysicalPlan interface { // getChildReqProps gets the required property by child index. getChildReqProps(idx int) *requiredProp - // StatsInfo will return the statsInfo for this plan. - StatsInfo() *statsInfo - // Get all the children. Children() []PhysicalPlan @@ -270,6 +270,10 @@ func (p *baseLogicalPlan) buildKeyInfo() { } } +func (p *DataSource) StatsInfo() *statsInfo { + return p.statsAfterSelect +} + func newBasePlan(ctx sessionctx.Context, tp string) basePlan { ctx.GetSessionVars().PlanID++ id := ctx.GetSessionVars().PlanID diff --git a/plan/stats.go b/plan/stats.go index 3d26c43d5f354..02dc6dd588e80 100644 --- a/plan/stats.go +++ b/plan/stats.go @@ -59,7 +59,7 @@ func (s *statsInfo) scaleByExpectCnt(expectCnt float64) *statsInfo { return s } -func (p *basePhysicalPlan) StatsInfo() *statsInfo { +func (p *basePlan) StatsInfo() *statsInfo { return p.stats }