Skip to content

Commit

Permalink
statistics: improve estimation for index equal condition (#17366) (#1…
Browse files Browse the repository at this point in the history
…7609)

Signed-off-by: sre-bot <sre-bot@pingcap.com>
  • Loading branch information
sre-bot authored Jul 24, 2020
1 parent bf298cc commit 0f44fef
Show file tree
Hide file tree
Showing 5 changed files with 58,390 additions and 14 deletions.
29 changes: 29 additions & 0 deletions planner/core/cbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1050,3 +1050,32 @@ func (s *testAnalyzeSuite) TestUpdateProjEliminate(c *C) {
tk.MustExec("create table t(a int, b int)")
tk.MustExec("explain update t t1, (select distinct b from t) t2 set t1.b = t2.b")
}

func (s *testAnalyzeSuite) TestIndexEqualUnknown(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
testKit := testkit.NewTestKit(c, store)
defer func() {
dom.Close()
store.Close()
}()
testKit.MustExec("use test")
testKit.MustExec("drop table if exists t, t1")
testKit.MustExec("CREATE TABLE t(a bigint(20) NOT NULL, b bigint(20) NOT NULL, c bigint(20) NOT NULL, PRIMARY KEY (a,c,b), KEY (b))")
err = s.loadTableStats("analyzeSuiteTestIndexEqualUnknownT.json", dom)
c.Assert(err, IsNil)
var input []string
var output []struct {
SQL string
Plan []string
}
s.testData.GetTestCases(c, &input, &output)
for i, tt := range input {
s.testData.OnRecord(func() {
output[i].SQL = tt
output[i].Plan = s.testData.ConvertRowsToStrings(testKit.MustQuery(tt).Rows())
})
testKit.MustQuery(tt).Check(testkit.Rows(output[i].Plan...))
}
}
Loading

0 comments on commit 0f44fef

Please sign in to comment.