Skip to content
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: add Fix52592 to control disallow fast path for select statement #56097

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,9 @@ func findBestTask4DS(ds *DataSource, prop *property.PhysicalProperty, planCounte
}

canConvertPointGet := len(path.Ranges) > 0 && path.StoreType == kv.TiKV && isPointGetConvertableSchema(ds)
if fixcontrol.GetBoolWithDefault(ds.SCtx().GetSessionVars().OptimizerFixControl, fixcontrol.Fix52592, false) {
canConvertPointGet = false
}

if canConvertPointGet && path.Index != nil && path.Index.MVIndex {
canConvertPointGet = false // cannot use PointGet upon MVIndex
Expand Down
4 changes: 3 additions & 1 deletion pkg/planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/pingcap/tidb/pkg/planner/property"
"github.com/pingcap/tidb/pkg/planner/util"
"github.com/pingcap/tidb/pkg/planner/util/costusage"
"github.com/pingcap/tidb/pkg/planner/util/fixcontrol"
"github.com/pingcap/tidb/pkg/planner/util/optimizetrace"
"github.com/pingcap/tidb/pkg/privilege"
"github.com/pingcap/tidb/pkg/sessionctx"
Expand Down Expand Up @@ -892,7 +893,8 @@ func TryFastPlan(ctx base.PlanContext, node *resolve.NodeW) (p base.Plan) {
ctx.GetSessionVars().PlanColumnID.Store(0)
switch x := node.Node.(type) {
case *ast.SelectStmt:
if x.SelectIntoOpt != nil {
// TODO: move this up to cover Delete as well after we have finished the fix for https://github.com/pingcap/tidb/issues/38911
if x.SelectIntoOpt != nil || fixcontrol.GetBoolWithDefault(ctx.GetSessionVars().OptimizerFixControl, fixcontrol.Fix52592, false) {
return nil
}
defer func() {
Expand Down
10 changes: 10 additions & 0 deletions pkg/planner/util/fixcontrol/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ import (
)

const (
// Fix52592 controls whether to disallow fast path for Get and BatchGet.
// Fast path does not support column projection, so we need to disable it when column projection is required.
// Here are the common cases that column projection is required:
// 1. Wide tables with many columns, where applications only query a few columns.
// 2. JSON fields with large column values, where queries may not necessarily retrieve the values of JSON columns
// or only extract specific small JSON content.
// By default, fast path is enabled, when it's disabled, the optimizer will fallback to coproccessor.
// It should be only disabled when fast path is more expensive than coprocessor.
// See #52592
Fix52592 uint64 = 52592
// Fix33031 controls whether to disallow plan cache for partitioned
// tables (both prepared statments and non-prepared statements)
// See #33031
Expand Down