From 6c016ed41b5b8746de0d29836e08e49e4917008b Mon Sep 17 00:00:00 2001 From: yisaer Date: Mon, 13 Feb 2023 11:11:54 +0800 Subject: [PATCH] support --- executor/index_advise_test.go | 13 ++++++------- planner/core/exhaust_physical_plans.go | 6 +++--- sessionctx/variable/session.go | 4 ++-- sessionctx/variable/sysvar.go | 9 +++++++++ sessionctx/variable/tidb_vars.go | 3 +++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/executor/index_advise_test.go b/executor/index_advise_test.go index a50c294294cea..2e133d25502ff 100644 --- a/executor/index_advise_test.go +++ b/executor/index_advise_test.go @@ -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"}, @@ -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")) } @@ -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"}, @@ -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 ")) - 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 ")) } diff --git a/planner/core/exhaust_physical_plans.go b/planner/core/exhaust_physical_plans.go index 7c0ff0a4274fa..2e78d7f059b35 100644 --- a/planner/core/exhaust_physical_plans.go +++ b/planner/core/exhaust_physical_plans.go @@ -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 @@ -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 @@ -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) } diff --git a/sessionctx/variable/session.go b/sessionctx/variable/session.go index 9a2490d2bc424..0023148fe8059 100644 --- a/sessionctx/variable/session.go +++ b/sessionctx/variable/session.go @@ -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 diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 09fa1112af053..6a16cfa844fcd 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -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. diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index 3163487de511a..9d5cc3c5e93a0 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -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