Skip to content

Commit

Permalink
cp 982a616
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisaer committed Mar 6, 2023
1 parent 7b845f9 commit f16f700
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
14 changes: 7 additions & 7 deletions executor/index_advise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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 @@ -123,10 +123,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 @@ -183,7 +183,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_12"},
Expand All @@ -195,10 +195,10 @@ 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.MustExec("set @@session.tidb_enable_inl_join_inner_multi_pattern='ON'")
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 @@ -726,7 +726,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 @@ -742,7 +742,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 @@ -1050,7 +1050,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
7 changes: 3 additions & 4 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,9 @@ type SessionVars struct {
// When it is false, ANALYZE reads the latest data.
// When it is true, ANALYZE reads data on the snapshot at the beginning of ANALYZE.
EnableAnalyzeSnapshot bool

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

// EnableINLJoinInnerMultiPattern indicates whether enable multi pattern for index join inner side
EnableINLJoinInnerMultiPattern bool
}

// InitStatementContext initializes a StatementContext, the object is reused to reduce allocation.
Expand Down
9 changes: 9 additions & 0 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,15 @@ var defaultSysVars = []*SysVar{
s.EnableAnalyzeSnapshot = 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 @@ -652,6 +652,9 @@ const (
// When set to false, ANALYZE reads the latest data.
// When set to true, ANALYZE reads data on the snapshot at the beginning of ANALYZE.
TiDBEnableAnalyzeSnapshot = "tidb_enable_analyze_snapshot"

// 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

0 comments on commit f16f700

Please sign in to comment.