-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planner: make clear for MaybeOverOptimized4PlanCache #29782
Changes from 5 commits
255e59f
ad5f8f9
f8f208b
ea0d5f3
8388a33
d3f2c3c
4e674a1
b4e1341
0bd2492
6456199
28ac7b2
23f0a7a
7c3f7d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -920,12 +920,7 @@ func ContainCorrelatedColumn(exprs []Expression) bool { | |
// TODO: Do more careful check here. | ||
func MaybeOverOptimized4PlanCache(ctx sessionctx.Context, exprs []Expression) bool { | ||
// If we do not enable plan cache, all the optimization can work correctly. | ||
if !ctx.GetSessionVars().StmtCtx.UseCache { | ||
return false | ||
} | ||
if ctx.GetSessionVars().StmtCtx.MaybeOverOptimized4PlanCache { | ||
// If the current statement can not be cached. We should remove the mutable constant. | ||
RemoveMutableConst(ctx, exprs) | ||
if !ctx.GetSessionVars().StmtCtx.UseCache || ctx.GetSessionVars().StmtCtx.MaybeOverOptimized4PlanCache { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it be more readable if we change StmtCtx.MaybeOverOptimized4PlanCache to SkipPlanCache? Since we will since plan-cache, we can return false here so that other optimizations can continue. |
||
return false | ||
} | ||
return containMutableConst(ctx, exprs) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1459,6 +1459,9 @@ func (er *expressionRewriter) inToExpression(lLen int, not bool, tp *types.Field | |
} else { | ||
continue | ||
} | ||
} else if er.sctx.GetSessionVars().StmtCtx.MaybeOverOptimized4PlanCache { | ||
// We should remove the mutable constant for correctness, because it's value maybe changed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's value maybe -> its value may be |
||
expression.RemoveMutableConst(er.sctx, []expression.Expression{c}) | ||
} | ||
args[i], isExceptional = expression.RefineComparedConstant(er.sctx, *leftFt, c, opcode.EQ) | ||
if isExceptional { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's value maybe -> its value may be