Skip to content

Commit

Permalink
plan: only plans that have apply will add cache. (pingcap#2564)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored and shenli committed Jan 26, 2017
1 parent 19af8d7 commit 92208e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plan/optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package plan

import (
"github.com/juju/errors"
"github.com/ngaut/log"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/context"
"github.com/pingcap/tidb/expression"
Expand Down Expand Up @@ -82,7 +81,7 @@ func doOptimize(flag uint64, logic LogicalPlan, ctx context.Context, allocator *
return nil, errors.Trace(ErrCartesianProductUnsupported)
}
logic.ResolveIndicesAndCorCols()
return physicalOptimize(logic, allocator)
return physicalOptimize(flag, logic, allocator)
}

func logicalOptimize(flag uint64, logic LogicalPlan, ctx context.Context, alloc *idAllocator) (LogicalPlan, error) {
Expand All @@ -102,15 +101,16 @@ func logicalOptimize(flag uint64, logic LogicalPlan, ctx context.Context, alloc
return logic, errors.Trace(err)
}

func physicalOptimize(logic LogicalPlan, allocator *idAllocator) (PhysicalPlan, error) {
func physicalOptimize(flag uint64, logic LogicalPlan, allocator *idAllocator) (PhysicalPlan, error) {
info, err := logic.convert2PhysicalPlan(&requiredProperty{})
if err != nil {
return nil, errors.Trace(err)
}
pp := info.p
pp = EliminateProjection(pp)
addCachePlan(pp, allocator)
log.Debugf("[PLAN] %s", ToString(pp))
if flag&(flagDecorrelate) > 0 {
addCachePlan(pp, allocator)
}
return pp, nil
}

Expand Down

0 comments on commit 92208e2

Please sign in to comment.