Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 committed May 6, 2024
1 parent a3d52d5 commit d1d2855
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions pkg/planner/core/common_unity.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ func collectUnityInfo(p base.LogicalPlan, o *UnityOutput) {
o.Tables[tableName].Indexes[idxName] = &UnityIndexInfo{}
o.Tables[tableName].idx2id[idxName] = idx.ID
}
//if x.tableInfo.PKIsHandle || x.tableInfo.IsCommonHandle {
// idxName := tableName+".primary"
// result[tableName].Indexes[idxName] = &UnityIndexInfo{}
//}
if x.tableInfo.PKIsHandle {
idxName := tableName + ".primary"
o.Tables[tableName].Indexes[idxName] = &UnityIndexInfo{}
}
}
for _, col := range x.Schema().Columns{
for _, col := range x.Schema().Columns {
colName := strings.ToLower(col.OrigName)
tName := tblName(col.OrigName)
if tName == "" {
Expand Down Expand Up @@ -240,7 +240,11 @@ func fillUpStats(o *UnityOutput) {
}
}
for idxName, idx := range tblInfo.Indexes {
idxStats := tblStats.Indices[tblInfo.idx2id[idxName]]
idxID, ok := tblInfo.idx2id[idxName]
if !ok { // single-col PK
continue
}
idxStats := tblStats.Indices[idxID]
idx.NDV = int(idxStats.NDV)
idx.Nulls = int(idxStats.NullCount)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/core/common_unity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func TestUnity(t *testing.T) {
tk.MustExec(`create table t1 (a int, b int, c int, key(a))`)
tk.MustExec(`create table t2 (a int, b int, c int, key(a))`)
tk.MustExec(`create table t3 (a int, b int, c int, key(a))`)
tk.MustExec(`create table t4 (a int, b int, c int, primary key (a))`)
tk.MustExec(`create table t5 (a int, b int, c int, primary key (a, b))`)
tk.MustExec(`create table t4 (a int, b int, c int, primary key (a), key(c))`)
tk.MustExec(`create table t5 (a int, b int, c int, primary key (a, b), key(c))`)
//formatPrint(tk, `explain format='unity' select * from t1, t2 where t1.a=t2.a`)
//formatPrint(tk, `explain format='unity' select 1 from t1, t2, t3 where t1.a=t2.a and t2.a=t3.a`)
formatPrint(tk, `explain format='unity' select a from t4`)
Expand Down

0 comments on commit d1d2855

Please sign in to comment.