From d22b8d512bec20b54acfa742aed5a961fca7b729 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 16:14:35 +0800 Subject: [PATCH 01/13] add correctness tests about direct reading with ORDER BY and LIMIT --- executor/partition_table_test.go | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index b1ff32e15f729..7e7bf36882e9e 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -14,6 +14,10 @@ package executor_test import ( + "fmt" + "math/rand" + "strings" + . "github.com/pingcap/check" "github.com/pingcap/parser/model" "github.com/pingcap/tidb/infoschema" @@ -222,6 +226,43 @@ func (s *partitionTableSuite) TestPartitionInfoDisable(c *C) { tk.MustQuery("select * from t_info_null where (date = '2020-10-02' or date = '2020-10-06') and app = 'xxx' and media = '19003006'").Check(testkit.Rows()) } +func (s *partitionTableSuite) TestOrderByandLimit(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec("create database test_orderby_limit") + tk.MustExec("use test_orderby_limit") + tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") + + // range partition table + tk.MustExec(`create table trange(a int, b int, index idx_a(a)) partition by range(a) ( + partition p0 values less than(3), + partition p1 values less than (5), + partition p2 values less than(11));`) + + // regular table + tk.MustExec("create table tregular(a int, b int, index idx_a(a))") + + // generate some random data to be inserted + vals := make([]string, 0, 100) + for i := 0; i < 100; i++ { + vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(11), rand.Intn(20))) + } + + tk.MustExec("insert into trange values " + strings.Join(vals, ",")) + tk.MustExec("insert into tregular values " + strings.Join(vals, ",")) + + // generate some random querys + for i := 0; i < 10; i++ { + // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used + // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result + y := rand.Intn(20) + x := rand.Intn(100) + queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a limit %v;", x, y) + queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a limit %v;", x, y) + c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used + tk.MustQuery(queryPartition).Check(tk.MustQuery(queryRegular).Rows()) + } +} + func (s *globalIndexSuite) TestGlobalIndexScan(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("drop table if exists p") From 73e8b20511f0a36fce3a824ff3cd288cd6eeab29 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 16:37:21 +0800 Subject: [PATCH 02/13] sort results before check --- executor/partition_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 7e7bf36882e9e..7d9c150545b72 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -259,7 +259,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a limit %v;", x, y) queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used - tk.MustQuery(queryPartition).Check(tk.MustQuery(queryRegular).Rows()) + tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) } } From ff7b060f5bb76b15b43b8b43b6224975a05218eb Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 16:43:48 +0800 Subject: [PATCH 03/13] bugfix: prevent dual table --- executor/partition_table_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 7d9c150545b72..7f482826f2b70 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -254,8 +254,8 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { for i := 0; i < 10; i++ { // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result - y := rand.Intn(20) - x := rand.Intn(100) + x := rand.Intn(10) + y := rand.Intn(100) queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a limit %v;", x, y) queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used From bee66a87e533d7b73e63b4062ec4af157b22bb74 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 16:45:59 +0800 Subject: [PATCH 04/13] increase query number --- executor/partition_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 7f482826f2b70..bc7ab72e4e8dc 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -251,7 +251,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { tk.MustExec("insert into tregular values " + strings.Join(vals, ",")) // generate some random querys - for i := 0; i < 10; i++ { + for i := 0; i < 100; i++ { // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result x := rand.Intn(10) From ca03eac3f771cd130505e583aec39a48fe6e20fa Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 16:55:40 +0800 Subject: [PATCH 05/13] change ORDER BY columns --- executor/partition_table_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index bc7ab72e4e8dc..e0c6a46ab210c 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -256,8 +256,8 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result x := rand.Intn(10) y := rand.Intn(100) - queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a limit %v;", x, y) - queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a limit %v;", x, y) + queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a, b limit %v;", x, y) + queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a, b limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) } From eab6148320ea253d9a39408f68fa1743f8a402bd Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 16:57:52 +0800 Subject: [PATCH 06/13] skip in DATA RACE mode --- executor/partition_table_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index e0c6a46ab210c..b462f7ec82544 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -22,6 +22,7 @@ import ( "github.com/pingcap/parser/model" "github.com/pingcap/tidb/infoschema" "github.com/pingcap/tidb/sessionctx/variable" + "github.com/pingcap/tidb/util/israce" "github.com/pingcap/tidb/util/testkit" ) @@ -227,6 +228,10 @@ func (s *partitionTableSuite) TestPartitionInfoDisable(c *C) { } func (s *partitionTableSuite) TestOrderByandLimit(c *C) { + if israce.RaceEnabled { + c.Skip("exhaustive types test, skip race test") + } + tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("create database test_orderby_limit") tk.MustExec("use test_orderby_limit") From 43d4f1dc5c49de3ae199addd188b0c06321aec27 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 17:21:41 +0800 Subject: [PATCH 07/13] prevent LIMIT 0 --- executor/partition_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index b462f7ec82544..043171660c838 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -260,7 +260,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result x := rand.Intn(10) - y := rand.Intn(100) + y := rand.Intn(100) + 1 queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a, b limit %v;", x, y) queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a, b limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used From 2d3ea39ad3bc9f6e842d5329f1e87b2cbf6de8d7 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Fri, 7 May 2021 17:53:52 +0800 Subject: [PATCH 08/13] add more test cases --- executor/partition_table_test.go | 42 ++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 043171660c838..b972118bbc0c8 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -243,6 +243,9 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { partition p1 values less than (5), partition p2 values less than(11));`) + // hash partition table + tk.MustExec("create table thash(a int, b int, index idx_a(a), index idx_b(b)) partition by hash(a) partitions 4;") + // regular table tk.MustExec("create table tregular(a int, b int, index idx_a(a))") @@ -251,11 +254,11 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { for i := 0; i < 100; i++ { vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(11), rand.Intn(20))) } - tk.MustExec("insert into trange values " + strings.Join(vals, ",")) + tk.MustExec("insert into thash values " + strings.Join(vals, ",")) tk.MustExec("insert into tregular values " + strings.Join(vals, ",")) - // generate some random querys + // test indexLookUp for i := 0; i < 100; i++ { // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result @@ -266,6 +269,41 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) } + + // test tableReader + for i := 0; i < 100; i++ { + // explain select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // check if IndexLookUp is used + // select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // it can return the correct result + x := rand.Intn(10) + y := rand.Intn(100) + 1 + queryPartition := fmt.Sprintf("select * from trange ignore index(idx_a) where a > %v order by a, b limit %v;", x, y) + queryRegular := fmt.Sprintf("select * from tregular ignore index(idx_a) where a > %v order by a, b limit %v;", x, y) + c.Assert(tk.HasPlan(queryPartition, "TableReader"), IsTrue) // check if tableReader is used + tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) + } + + // test indexReader + for i := 0; i < 100; i++ { + // explain select a from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used + // select a from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result + x := rand.Intn(10) + y := rand.Intn(100) + 1 + queryPartition := fmt.Sprintf("select a from trange use index(idx_a) where a > %v order by a limit %v;", x, y) + queryRegular := fmt.Sprintf("select a from tregular use index(idx_a) where a > %v order by a limit %v;", x, y) + c.Assert(tk.HasPlan(queryPartition, "IndexReader"), IsTrue) // check if indexReader is used + tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) + } + + // test indexMerge + for i := 0; i < 100; i++ { + // explain select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // check if IndexMerge is used + // select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // can return the correct value + y := rand.Intn(100) + 1 + queryPartition := fmt.Sprintf("select /*+ use_index_merge(thash) */ * from thash where a > 2 or b < 5 order by a, b limit %v;", y) + queryRegular := fmt.Sprintf("select * from tregular where a > 2 or b < 5 order by a, b limit %v;", y) + c.Assert(tk.HasPlan(queryPartition, "IndexMerge"), IsTrue) // check if indexMerge is used + tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) + } } func (s *globalIndexSuite) TestGlobalIndexScan(c *C) { From 072f0733ad8f2b1ea6d7f972d97d74efb68206c4 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Sat, 8 May 2021 12:17:41 +0800 Subject: [PATCH 09/13] change partition range and data num --- executor/partition_table_test.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index b972118bbc0c8..bdd61403064c6 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -239,9 +239,9 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { // range partition table tk.MustExec(`create table trange(a int, b int, index idx_a(a)) partition by range(a) ( - partition p0 values less than(3), - partition p1 values less than (5), - partition p2 values less than(11));`) + partition p0 values less than(300), + partition p1 values less than (500), + partition p2 values less than(1100));`) // hash partition table tk.MustExec("create table thash(a int, b int, index idx_a(a), index idx_b(b)) partition by hash(a) partitions 4;") @@ -250,20 +250,20 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { tk.MustExec("create table tregular(a int, b int, index idx_a(a))") // generate some random data to be inserted - vals := make([]string, 0, 100) + vals := make([]string, 0, 2000) for i := 0; i < 100; i++ { - vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(11), rand.Intn(20))) + vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(1100), rand.Intn(2000))) } tk.MustExec("insert into trange values " + strings.Join(vals, ",")) tk.MustExec("insert into thash values " + strings.Join(vals, ",")) tk.MustExec("insert into tregular values " + strings.Join(vals, ",")) // test indexLookUp - for i := 0; i < 100; i++ { + for i := 0; i < 2000; i++ { // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result - x := rand.Intn(10) - y := rand.Intn(100) + 1 + x := rand.Intn(1099) + y := rand.Intn(2000) + 1 queryPartition := fmt.Sprintf("select * from trange use index(idx_a) where a > %v order by a, b limit %v;", x, y) queryRegular := fmt.Sprintf("select * from tregular use index(idx_a) where a > %v order by a, b limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "IndexLookUp"), IsTrue) // check if IndexLookUp is used @@ -271,11 +271,11 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { } // test tableReader - for i := 0; i < 100; i++ { + for i := 0; i < 2000; i++ { // explain select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // it can return the correct result - x := rand.Intn(10) - y := rand.Intn(100) + 1 + x := rand.Intn(1099) + y := rand.Intn(2000) + 1 queryPartition := fmt.Sprintf("select * from trange ignore index(idx_a) where a > %v order by a, b limit %v;", x, y) queryRegular := fmt.Sprintf("select * from tregular ignore index(idx_a) where a > %v order by a, b limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "TableReader"), IsTrue) // check if tableReader is used @@ -283,11 +283,11 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { } // test indexReader - for i := 0; i < 100; i++ { + for i := 0; i < 2000; i++ { // explain select a from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select a from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result - x := rand.Intn(10) - y := rand.Intn(100) + 1 + x := rand.Intn(1099) + y := rand.Intn(2000) + 1 queryPartition := fmt.Sprintf("select a from trange use index(idx_a) where a > %v order by a limit %v;", x, y) queryRegular := fmt.Sprintf("select a from tregular use index(idx_a) where a > %v order by a limit %v;", x, y) c.Assert(tk.HasPlan(queryPartition, "IndexReader"), IsTrue) // check if indexReader is used @@ -295,10 +295,10 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { } // test indexMerge - for i := 0; i < 100; i++ { + for i := 0; i < 2000; i++ { // explain select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // check if IndexMerge is used // select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // can return the correct value - y := rand.Intn(100) + 1 + y := rand.Intn(2000) + 1 queryPartition := fmt.Sprintf("select /*+ use_index_merge(thash) */ * from thash where a > 2 or b < 5 order by a, b limit %v;", y) queryRegular := fmt.Sprintf("select * from tregular where a > 2 or b < 5 order by a, b limit %v;", y) c.Assert(tk.HasPlan(queryPartition, "IndexMerge"), IsTrue) // check if indexMerge is used From 1e0bbb6579a1c752f2f07b2c4464c4d5221de9d9 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Sat, 8 May 2021 12:18:48 +0800 Subject: [PATCH 10/13] change data num --- executor/partition_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index bdd61403064c6..2cfb254e48255 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -251,7 +251,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { // generate some random data to be inserted vals := make([]string, 0, 2000) - for i := 0; i < 100; i++ { + for i := 0; i < 2000; i++ { vals = append(vals, fmt.Sprintf("(%v, %v)", rand.Intn(1100), rand.Intn(2000))) } tk.MustExec("insert into trange values " + strings.Join(vals, ",")) From aad8212d79cb6513c9cfa87b4187509d83750a49 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Sat, 8 May 2021 12:46:59 +0800 Subject: [PATCH 11/13] resolve conflict --- executor/partition_table_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 916cba752f23d..1dab498aa7fa3 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -227,17 +227,12 @@ func (s *partitionTableSuite) TestPartitionInfoDisable(c *C) { tk.MustQuery("select * from t_info_null where (date = '2020-10-02' or date = '2020-10-06') and app = 'xxx' and media = '19003006'").Check(testkit.Rows()) } -<<<<<<< HEAD func (s *partitionTableSuite) TestOrderByandLimit(c *C) { -======= -func (s *partitionTableSuite) TestGlobalStatsAndSQLBinding(c *C) { ->>>>>>> 82ea46d652970bb564a43d3effc04334f3bf9d0b if israce.RaceEnabled { c.Skip("exhaustive types test, skip race test") } tk := testkit.NewTestKitWithInit(c, s.store) -<<<<<<< HEAD tk.MustExec("create database test_orderby_limit") tk.MustExec("use test_orderby_limit") tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") @@ -309,7 +304,14 @@ func (s *partitionTableSuite) TestGlobalStatsAndSQLBinding(c *C) { c.Assert(tk.HasPlan(queryPartition, "IndexMerge"), IsTrue) // check if indexMerge is used tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) } -======= +} + +func (s *partitionTableSuite) TestGlobalStatsAndSQLBinding(c *C) { + if israce.RaceEnabled { + c.Skip("exhaustive types test, skip race test") + } + + tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("create database test_global_stats") tk.MustExec("use test_global_stats") tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") @@ -380,7 +382,6 @@ func (s *partitionTableSuite) TestGlobalStatsAndSQLBinding(c *C) { tk.MustIndexLookup("select * from thash where a<100") tk.MustIndexLookup("select * from trange where a<100") tk.MustIndexLookup("select * from tlist where a<1") ->>>>>>> 82ea46d652970bb564a43d3effc04334f3bf9d0b } func (s *globalIndexSuite) TestGlobalIndexScan(c *C) { From 2114d60e8f1d18d93785ffa8adb135a04be55967 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Mon, 10 May 2021 19:17:46 +0800 Subject: [PATCH 12/13] resolve merge conflict --- executor/partition_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index a9329186f57e9..3aab5b6d05abf 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -303,7 +303,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { queryRegular := fmt.Sprintf("select * from tregular where a > 2 or b < 5 order by a, b limit %v;", y) c.Assert(tk.HasPlan(queryPartition, "IndexMerge"), IsTrue) // check if indexMerge is used tk.MustQuery(queryPartition).Sort().Check(tk.MustQuery(queryRegular).Sort().Rows()) - } + } } func (s *partitionTableSuite) TestView(c *C) { From 0449db5c1b2be4cbea22fb78609391ac1e31e5c7 Mon Sep 17 00:00:00 2001 From: zhuo-zhi <517770911@qq.com> Date: Thu, 13 May 2021 12:33:58 +0800 Subject: [PATCH 13/13] decrease query number --- executor/partition_table_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 8eedc131d9448..7a3753199cf1c 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -259,7 +259,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { tk.MustExec("insert into tregular values " + strings.Join(vals, ",")) // test indexLookUp - for i := 0; i < 2000; i++ { + for i := 0; i < 100; i++ { // explain select * from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result x := rand.Intn(1099) @@ -271,7 +271,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { } // test tableReader - for i := 0; i < 2000; i++ { + for i := 0; i < 100; i++ { // explain select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select * from t where a > {y} ignore index(idx_a) order by a limit {x}; // it can return the correct result x := rand.Intn(1099) @@ -283,7 +283,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { } // test indexReader - for i := 0; i < 2000; i++ { + for i := 0; i < 100; i++ { // explain select a from t where a > {y} use index(idx_a) order by a limit {x}; // check if IndexLookUp is used // select a from t where a > {y} use index(idx_a) order by a limit {x}; // it can return the correct result x := rand.Intn(1099) @@ -295,7 +295,7 @@ func (s *partitionTableSuite) TestOrderByandLimit(c *C) { } // test indexMerge - for i := 0; i < 2000; i++ { + for i := 0; i < 100; i++ { // explain select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // check if IndexMerge is used // select /*+ use_index_merge(t) */ * from t where a > 2 or b < 5 order by a limit {x}; // can return the correct value y := rand.Intn(2000) + 1