Skip to content

Commit 92208e2

Browse files
hanfei1991shenli
authored andcommitted
plan: only plans that have apply will add cache. (#2564)
1 parent 19af8d7 commit 92208e2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

plan/optimizer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package plan
1515

1616
import (
1717
"github.com/juju/errors"
18-
"github.com/ngaut/log"
1918
"github.com/pingcap/tidb/ast"
2019
"github.com/pingcap/tidb/context"
2120
"github.com/pingcap/tidb/expression"
@@ -82,7 +81,7 @@ func doOptimize(flag uint64, logic LogicalPlan, ctx context.Context, allocator *
8281
return nil, errors.Trace(ErrCartesianProductUnsupported)
8382
}
8483
logic.ResolveIndicesAndCorCols()
85-
return physicalOptimize(logic, allocator)
84+
return physicalOptimize(flag, logic, allocator)
8685
}
8786

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

105-
func physicalOptimize(logic LogicalPlan, allocator *idAllocator) (PhysicalPlan, error) {
104+
func physicalOptimize(flag uint64, logic LogicalPlan, allocator *idAllocator) (PhysicalPlan, error) {
106105
info, err := logic.convert2PhysicalPlan(&requiredProperty{})
107106
if err != nil {
108107
return nil, errors.Trace(err)
109108
}
110109
pp := info.p
111110
pp = EliminateProjection(pp)
112-
addCachePlan(pp, allocator)
113-
log.Debugf("[PLAN] %s", ToString(pp))
111+
if flag&(flagDecorrelate) > 0 {
112+
addCachePlan(pp, allocator)
113+
}
114114
return pp, nil
115115
}
116116

0 commit comments

Comments
 (0)