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

statistics: prioritize low selectivity indexes in ... (#20038) #20154

Merged
merged 5 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions planner/core/cbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,38 @@ func (s *testAnalyzeSuite) TestLimitCrossEstimation(c *C) {
}
}

func (s *testAnalyzeSuite) TestLowSelIndexGreedySearch(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")
testKit.MustExec("create table t (a varchar(32) default null, b varchar(10) default null, c varchar(12) default null, d varchar(32) default null, e bigint(10) default null, key idx1 (d,a), key idx2 (a,c), key idx3 (c,b), key idx4 (e))")
err = s.loadTableStats("analyzeSuiteTestLowSelIndexGreedySearchT.json", dom)
c.Assert(err, IsNil)
var input []string
var output []struct {
SQL string
Plan []string
}
// The test purposes are:
// - index `idx2` runs much faster than `idx4` experimentally;
// - estimated row count of IndexLookUp should be 0;
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...))
}
}

func (s *testAnalyzeSuite) TestUpdateProjEliminate(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down
Loading