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

sysvar: introduce variable tidb_enable_inl_join_inner_multi_pattern #41319

Merged
merged 1 commit into from
Feb 13, 2023
Merged
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
13 changes: 6 additions & 7 deletions executor/index_advise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ and b.txn_accno = a.new_accno;`
{" └─Selection_11"},
{" └─IndexRangeScan_10"},
}
tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = true
tk.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='ON'")
tk.MustQuery("explain "+sql).CheckAt([]int{0}, rows)
rows = [][]interface{}{
{"Update_8"},
Expand All @@ -118,10 +118,10 @@ and b.txn_accno = a.new_accno;`
{" └─Selection_13"},
{" └─TableFullScan_12"},
}
tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = false
tk.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='OFF'")
tk.MustQuery("explain "+sql).CheckAt([]int{0}, rows)

tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = true
tk.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='ON'")
tk.MustExec(sql)
tk.MustQuery("select yn_frz from t2").Check(testkit.Rows("1"))
}
Expand Down Expand Up @@ -177,7 +177,7 @@ txn_dt date default null
{" └─Selection_15"},
{" └─TableFullScan_14"},
}
tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = false
tk.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='OFF'")
tk.MustQuery("explain "+sql).CheckAt([]int{0}, rows)
rows = [][]interface{}{
{"IndexJoin_13"},
Expand All @@ -190,10 +190,9 @@ txn_dt date default null
{" └─Selection_10(Probe)"},
{" └─TableRowIDScan_9"},
}
tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = true
tk.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='ON'")
tk.MustQuery("explain "+sql).CheckAt([]int{0}, rows)
tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = true
tk.MustQuery(sql).Check(testkit.Rows("1 2022-12-01 123 1 2022-12-01 123 1 <nil>"))
tk.Session().GetSessionVars().EnableIndexJoinInnerSideMultiPattern = false
tk.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='OFF'")
tk.MustQuery(sql).Check(testkit.Rows("1 2022-12-01 123 1 2022-12-01 123 1 <nil>"))
}
6 changes: 3 additions & 3 deletions planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ func (p *LogicalJoin) extractIndexJoinInnerChildPattern(innerChild LogicalPlan)
}
}
case *LogicalProjection:
if !p.ctx.GetSessionVars().EnableIndexJoinInnerSideMultiPattern {
if !p.ctx.GetSessionVars().EnableINLJoinInnerMultiPattern {
return nil
}
// For now, we only allow proj with all Column expression can be the inner side of index join
Expand All @@ -775,7 +775,7 @@ func (p *LogicalJoin) extractIndexJoinInnerChildPattern(innerChild LogicalPlan)
}
wrapper.ds = ds
case *LogicalSelection:
if !p.ctx.GetSessionVars().EnableIndexJoinInnerSideMultiPattern {
if !p.ctx.GetSessionVars().EnableINLJoinInnerMultiPattern {
return nil
}
wrapper.sel = child
Expand Down Expand Up @@ -1092,7 +1092,7 @@ func (p *LogicalJoin) constructInnerTableScanTask(
}

func (p *LogicalJoin) constructInnerByWrapper(wrapper *indexJoinInnerChildWrapper, child PhysicalPlan) PhysicalPlan {
if !p.ctx.GetSessionVars().EnableIndexJoinInnerSideMultiPattern {
if !p.ctx.GetSessionVars().EnableINLJoinInnerMultiPattern {
if wrapper.us != nil {
return p.constructInnerUnionScan(wrapper.us, child)
}
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,9 @@ type SessionVars struct {
// is enabled.
PessimisticTransactionAggressiveLocking bool

// EnableIndexJoinInnerSideMultiPattern indicates whether enable multi pattern for index join inner side
// EnableINLJoinInnerMultiPattern indicates whether enable multi pattern for index join inner side
// For now it is not public to user
EnableIndexJoinInnerSideMultiPattern bool
EnableINLJoinInnerMultiPattern bool
}

// planReplayerSessionFinishedTaskKeyLen is used to control the max size for the finished plan replayer task key in session
Expand Down
9 changes: 9 additions & 0 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,15 @@ var defaultSysVars = []*SysVar{
s.EnablePlanCacheForParamLimit = TiDBOptOn(val)
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableINLJoinInnerMultiPattern, Value: BoolToOnOff(false), Type: TypeBool,
SetSession: func(s *SessionVars, val string) error {
s.EnableINLJoinInnerMultiPattern = TiDBOptOn(val)
return nil
},
GetSession: func(s *SessionVars) (string, error) {
return BoolToOnOff(s.EnableINLJoinInnerMultiPattern), nil
},
},
}

// FeedbackProbability points to the FeedbackProbability in statistics package.
Expand Down
3 changes: 3 additions & 0 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,9 @@ const (

// TiDBEnablePlanCacheForParamLimit controls whether prepare statement with parameterized limit can be cached
TiDBEnablePlanCacheForParamLimit = "tidb_enable_plan_cache_for_param_limit"

// TiDBEnableINLJoinInnerMultiPattern indicates whether enable multi pattern for inner side of inl join
TiDBEnableINLJoinInnerMultiPattern = "tidb_enable_inl_join_inner_multi_pattern"
)

// TiDB vars that have only global scope
Expand Down