From d266d7cfe21f9457064537cf8db3c4d8228a396a Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 11 May 2021 15:21:29 +0200 Subject: [PATCH 1/7] Added partitioning pruning tests for range partitioning --- executor/partition_table_test.go | 43 +++ executor/testdata/executor_suite_in.json | 41 +++ executor/testdata/executor_suite_out.json | 391 +++++++++++++++++++++- util/testkit/testkit.go | 13 + 4 files changed, 487 insertions(+), 1 deletion(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index b1ff32e15f729..1d52fc52103e7 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -14,6 +14,8 @@ package executor_test import ( + "strings" + . "github.com/pingcap/check" "github.com/pingcap/parser/model" "github.com/pingcap/tidb/infoschema" @@ -251,3 +253,44 @@ func (s *globalIndexSuite) TestIssue21731(c *C) { tk.MustExec("drop table if exists p, t") tk.MustExec("create table t (a int, b int, unique index idx(a)) partition by list columns(b) (partition p0 values in (1), partition p1 values in (2));") } + +func (s *testSuiteWithData) TestRangePartitionBoundaries(c *C) { + tk := testkit.NewTestKit(c, s.store) + + tk.MustExec("create database TestRangePartitionBoundaries") + tk.MustExec("use TestRangePartitionBoundaries") + tk.MustExec(`CREATE TABLE t +(a INT, b varchar(255)) +PARTITION BY RANGE (a) ( + PARTITION p0 VALUES LESS THAN (1000000), + PARTITION p1 VALUES LESS THAN (2000000), + PARTITION p2 VALUES LESS THAN (3000000)); +`) + + var input []string + var output []struct { + SQL string + Plan []string + Res []string + } + s.testData.GetTestCases(c, &input, &output) + for i, tt := range input { + var isInsert bool = false + if strings.HasPrefix(strings.ToLower(tt), "insert ") { + isInsert = true + } + s.testData.OnRecord(func() { + output[i].SQL = tt + output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("explain format = 'brief' " + tt).Rows()) + if isInsert { + // to avoid double execution of INSERT (and INSERT does not return anything) + output[i].Res = nil + } else { + output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) + } + }) + tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) + } + tk.MustExec("drop database TestRangePartitionBoundaries") +} diff --git a/executor/testdata/executor_suite_in.json b/executor/testdata/executor_suite_in.json index 6abd20c740a80..a76d255e5bc2b 100644 --- a/executor/testdata/executor_suite_in.json +++ b/executor/testdata/executor_suite_in.json @@ -51,5 +51,46 @@ "select count(*) from t as t1 left join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL", "select * from t as t1 left join t as t2 on t1.c1 = t2.c1 where t1.c1 is not NULL" ] + }, + { + "name": "TestRangePartitionBoundaries", + "cases": [ + "INSERT INTO t VALUES (999998, '999998 Filler ...'), (999999, '999999 Filler ...'), (1000000, '1000000 Filler ...'), (1000001, '1000001 Filler ...'), (1000002, '1000002 Filler ...')", + "INSERT INTO t VALUES (1999998, '1999998 Filler ...'), (1999999, '1999999 Filler ...'), (2000000, '2000000 Filler ...'), (2000001, '2000001 Filler ...'), (2000002, '2000002 Filler ...')", + "INSERT INTO t VALUES (2999998, '2999998 Filler ...'), (2999999, '2999999 Filler ...')", + "INSERT INTO t VALUES (-2147483648, 'MIN_INT filler...'), (0, '0 Filler...')", + "SELECT * FROM t WHERE a = -2147483648", + "SELECT * FROM t WHERE a IN (-2147483648)", + "SELECT * FROM t WHERE a = 0", + "SELECT * FROM t WHERE a IN (0)", + "SELECT * FROM t WHERE a = 999998", + "SELECT * FROM t WHERE a IN (999998)", + "SELECT * FROM t WHERE a = 999999", + "SELECT * FROM t WHERE a IN (999999)", + "SELECT * FROM t WHERE a = 1000000", + "SELECT * FROM t WHERE a IN (1000000)", + "SELECT * FROM t WHERE a = 1000001", + "SELECT * FROM t WHERE a IN (1000001)", + "SELECT * FROM t WHERE a = 1000002", + "SELECT * FROM t WHERE a IN (1000002)", + "SELECT * FROM t WHERE a = 3000000", + "SELECT * FROM t WHERE a IN (3000000)", + "SELECT * FROM t WHERE a = 3000001", + "SELECT * FROM t WHERE a IN (3000001)", + "SELECT * FROM t WHERE a IN (-2147483648, -2147483647)", + "SELECT * FROM t WHERE a IN (-2147483647, -2147483646)", + "SELECT * FROM t WHERE a IN (999997, 999998, 999999)", + "SELECT * FROM t WHERE a IN (999998, 999999, 1000000)", + "SELECT * FROM t WHERE a IN (999999, 1000000, 1000001)", + "SELECT * FROM t WHERE a IN (1000000, 1000001, 1000002)", + "SELECT * FROM t WHERE a IN (1999997, 1999998, 1999999)", + "SELECT * FROM t WHERE a IN (1999998, 1999999, 2000000)", + "SELECT * FROM t WHERE a IN (1999999, 2000000, 2000001)", + "SELECT * FROM t WHERE a IN (2000000, 2000001, 2000002)", + "SELECT * FROM t WHERE a IN (2999997, 2999998, 2999999)", + "SELECT * FROM t WHERE a IN (2999998, 2999999, 3000000)", + "SELECT * FROM t WHERE a IN (2999999, 3000000, 3000001)", + "SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002)" + ] } ] diff --git a/executor/testdata/executor_suite_out.json b/executor/testdata/executor_suite_out.json index 2be3c8ea4894f..c0c2aa7f5fd96 100644 --- a/executor/testdata/executor_suite_out.json +++ b/executor/testdata/executor_suite_out.json @@ -598,5 +598,394 @@ ] } ] - } + }, + { + "Name": "TestRangePartitionBoundaries", + "Cases": [ + { + "SQL": "INSERT INTO t VALUES (999998, '999998 Filler ...'), (999999, '999999 Filler ...'), (1000000, '1000000 Filler ...'), (1000001, '1000001 Filler ...'), (1000002, '1000002 Filler ...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (1999998, '1999998 Filler ...'), (1999999, '1999999 Filler ...'), (2000000, '2000000 Filler ...'), (2000001, '2000001 Filler ...'), (2000002, '2000002 Filler ...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (2999998, '2999998 Filler ...'), (2999999, '2999999 Filler ...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (-2147483648, 'MIN_INT filler...'), (0, '0 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a = -2147483648", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "-2147483648 MIN_INT filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (-2147483648)", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "-2147483648 MIN_INT filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 0", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (0)", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 999998", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "999998 999998 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (999998)", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "999998 999998 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 999999", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "999999 999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (999999)", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "999999 999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 1000000", + "Plan": [ + "TableReader 10.00 root partition:p1 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000000 1000000 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1000000)", + "Plan": [ + "TableReader 10.00 root partition:p1 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000000 1000000 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 1000001", + "Plan": [ + "TableReader 10.00 root partition:p1 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000001 1000001 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1000001)", + "Plan": [ + "TableReader 10.00 root partition:p1 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000001 1000001 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 1000002", + "Plan": [ + "TableReader 10.00 root partition:p1 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000002 1000002 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1000002)", + "Plan": [ + "TableReader 10.00 root partition:p1 data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000002 1000002 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a = 3000000", + "Plan": [ + "TableReader 10.00 root partition:dual data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a IN (3000000)", + "Plan": [ + "TableReader 10.00 root partition:dual data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a = 3000001", + "Plan": [ + "TableReader 10.00 root partition:dual data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a IN (3000001)", + "Plan": [ + "TableReader 10.00 root partition:dual data:Selection", + "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a IN (-2147483648, -2147483647)", + "Plan": [ + "TableReader 20.00 root partition:p0 data:Selection", + "└─Selection 20.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483648, -2147483647)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "-2147483648 MIN_INT filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (-2147483647, -2147483646)", + "Plan": [ + "TableReader 20.00 root partition:p0 data:Selection", + "└─Selection 20.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483647, -2147483646)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a IN (999997, 999998, 999999)", + "Plan": [ + "TableReader 30.00 root partition:p0 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999997, 999998, 999999)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "999998 999998 Filler ...", + "999999 999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (999998, 999999, 1000000)", + "Plan": [ + "TableReader 30.00 root partition:p0,p1 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999998, 999999, 1000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000000 1000000 Filler ...", + "999998 999998 Filler ...", + "999999 999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (999999, 1000000, 1000001)", + "Plan": [ + "TableReader 30.00 root partition:p0,p1 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999999, 1000000, 1000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000000 1000000 Filler ...", + "1000001 1000001 Filler ...", + "999999 999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1000000, 1000001, 1000002)", + "Plan": [ + "TableReader 30.00 root partition:p1 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1000000, 1000001, 1000002)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1000000 1000000 Filler ...", + "1000001 1000001 Filler ...", + "1000002 1000002 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1999997, 1999998, 1999999)", + "Plan": [ + "TableReader 30.00 root partition:p1 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999997, 1999998, 1999999)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1999998 1999998 Filler ...", + "1999999 1999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1999998, 1999999, 2000000)", + "Plan": [ + "TableReader 30.00 root partition:p1,p2 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999998, 1999999, 2000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1999998 1999998 Filler ...", + "1999999 1999999 Filler ...", + "2000000 2000000 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (1999999, 2000000, 2000001)", + "Plan": [ + "TableReader 30.00 root partition:p1,p2 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999999, 2000000, 2000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1999999 1999999 Filler ...", + "2000000 2000000 Filler ...", + "2000001 2000001 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (2000000, 2000001, 2000002)", + "Plan": [ + "TableReader 30.00 root partition:p2 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2000000, 2000001, 2000002)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "2000000 2000000 Filler ...", + "2000001 2000001 Filler ...", + "2000002 2000002 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (2999997, 2999998, 2999999)", + "Plan": [ + "TableReader 30.00 root partition:p2 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999997, 2999998, 2999999)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "2999998 2999998 Filler ...", + "2999999 2999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (2999998, 2999999, 3000000)", + "Plan": [ + "TableReader 30.00 root partition:p2 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999998, 2999999, 3000000)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "2999998 2999998 Filler ...", + "2999999 2999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (2999999, 3000000, 3000001)", + "Plan": [ + "TableReader 30.00 root partition:p2 data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999999, 3000000, 3000001)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "2999999 2999999 Filler ..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002)", + "Plan": [ + "TableReader 30.00 root partition:dual data:Selection", + "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 3000000, 3000001, 3000002)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + } + ] + } ] diff --git a/util/testkit/testkit.go b/util/testkit/testkit.go index 4992e28663b1a..93a9bd3cc916d 100644 --- a/util/testkit/testkit.go +++ b/util/testkit/testkit.go @@ -296,6 +296,19 @@ func (tk *TestKit) MustQuery(sql string, args ...interface{}) *Result { return tk.ResultSetToResult(rs, comment) } +// MayQuery query the statements and returns result rows if result set is returned. +// If expected result is set it asserts the query result equals expected result. +func (tk *TestKit) MayQuery(sql string, args ...interface{}) *Result { + comment := check.Commentf("sql:%s, args:%v", sql, args) + rs, err := tk.Exec(sql, args...) + tk.c.Assert(errors.ErrorStack(err), check.Equals, "", comment) + if rs == nil { + var emptyStringAoA [][]string + return &Result{rows: emptyStringAoA, c: tk.c, comment: comment} + } + return tk.ResultSetToResult(rs, comment) +} + // QueryToErr executes a sql statement and discard results. func (tk *TestKit) QueryToErr(sql string, args ...interface{}) error { comment := check.Commentf("sql:%s, args:%v", sql, args) From 9caf31411ecf3d97787ee29039cf278447e46243 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 11 May 2021 16:17:19 +0200 Subject: [PATCH 2/7] partition range pruning boundaries tests, more Ne tests --- executor/partition_table_test.go | 47 +- executor/testdata/executor_suite_in.json | 50 +- executor/testdata/executor_suite_out.json | 560 +++++++++++++++++++++- 3 files changed, 652 insertions(+), 5 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 19571fd3c4276..dd7566ef2892b 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -14,7 +14,6 @@ package executor_test import ( - "fmt" "math/rand" "strings" @@ -675,7 +674,7 @@ func (s *globalIndexSuite) TestIssue21731(c *C) { tk.MustExec("create table t (a int, b int, unique index idx(a)) partition by list columns(b) (partition p0 values in (1), partition p1 values in (2));") } -func (s *testSuiteWithData) TestRangePartitionBoundaries(c *C) { +func (s *testSuiteWithData) TestRangePartitionBoundariesEq(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("create database TestRangePartitionBoundaries") @@ -715,3 +714,47 @@ PARTITION BY RANGE (a) ( } tk.MustExec("drop database TestRangePartitionBoundaries") } + +func (s *testSuiteWithData) TestRangePartitionBoundariesNe(c *C) { + tk := testkit.NewTestKit(c, s.store) + + tk.MustExec("create database TestRangePartitionBoundariesNe") + tk.MustExec("use TestRangePartitionBoundariesNe") + tk.MustExec(`CREATE TABLE t +(a INT, b varchar(255)) +PARTITION BY RANGE (a) ( + PARTITION p0 VALUES LESS THAN (1), + PARTITION p1 VALUES LESS THAN (2), + PARTITION p2 VALUES LESS THAN (3), + PARTITION p3 VALUES LESS THAN (4), + PARTITION p4 VALUES LESS THAN (5), + PARTITION p5 VALUES LESS THAN (6), + PARTITION p6 VALUES LESS THAN (7))`) + + var input []string + var output []struct { + SQL string + Plan []string + Res []string + } + s.testData.GetTestCases(c, &input, &output) + for i, tt := range input { + var isInsert bool = false + if strings.HasPrefix(strings.ToLower(tt), "insert ") { + isInsert = true + } + s.testData.OnRecord(func() { + output[i].SQL = tt + output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("explain format = 'brief' " + tt).Rows()) + if isInsert { + // to avoid double execution of INSERT (and INSERT does not return anything) + output[i].Res = nil + } else { + output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) + } + }) + tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) + } + tk.MustExec("drop database TestRangePartitionBoundariesNe") +} diff --git a/executor/testdata/executor_suite_in.json b/executor/testdata/executor_suite_in.json index a76d255e5bc2b..77f311b3f3b0e 100644 --- a/executor/testdata/executor_suite_in.json +++ b/executor/testdata/executor_suite_in.json @@ -53,7 +53,7 @@ ] }, { - "name": "TestRangePartitionBoundaries", + "name": "TestRangePartitionBoundariesEq", "cases": [ "INSERT INTO t VALUES (999998, '999998 Filler ...'), (999999, '999999 Filler ...'), (1000000, '1000000 Filler ...'), (1000001, '1000001 Filler ...'), (1000002, '1000002 Filler ...')", "INSERT INTO t VALUES (1999998, '1999998 Filler ...'), (1999999, '1999999 Filler ...'), (2000000, '2000000 Filler ...'), (2000001, '2000001 Filler ...'), (2000002, '2000002 Filler ...')", @@ -92,5 +92,53 @@ "SELECT * FROM t WHERE a IN (2999999, 3000000, 3000001)", "SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002)" ] + }, + { + "name": "TestRangePartitionBoundariesNe", + "cases": [ + "INSERT INTO t VALUES (0, '0 Filler...')", + "INSERT INTO t VALUES (1, '1 Filler...')", + "INSERT INTO t VALUES (2, '2 Filler...')", + "INSERT INTO t VALUES (3, '3 Filler...')", + "INSERT INTO t VALUES (4, '4 Filler...')", + "INSERT INTO t VALUES (5, '5 Filler...')", + "INSERT INTO t VALUES (6, '6 Filler...')", + "SELECT * FROM t WHERE a != -1", + "SELECT * FROM t WHERE 1 = 1 AND a != -1", + "SELECT * FROM t WHERE a NOT IN (-2, -1)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1", + "SELECT * FROM t WHERE a != 0", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0", + "SELECT * FROM t WHERE a != 1", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1", + "SELECT * FROM t WHERE a != 2", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2", + "SELECT * FROM t WHERE a != 3", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3", + "SELECT * FROM t WHERE a != 4", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4", + "SELECT * FROM t WHERE a != 5", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5", + "SELECT * FROM t WHERE a != 6", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6", + "SELECT * FROM t WHERE a != 7", + "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6 AND a != 7", + "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6, 7)", + "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6 OR a = 7" + ] } ] diff --git a/executor/testdata/executor_suite_out.json b/executor/testdata/executor_suite_out.json index c0c2aa7f5fd96..2b1c0a6fdb2fb 100644 --- a/executor/testdata/executor_suite_out.json +++ b/executor/testdata/executor_suite_out.json @@ -600,7 +600,7 @@ ] }, { - "Name": "TestRangePartitionBoundaries", + "Name": "TestRangePartitionBoundariesEq", "Cases": [ { "SQL": "INSERT INTO t VALUES (999998, '999998 Filler ...'), (999999, '999999 Filler ...'), (1000000, '1000000 Filler ...'), (1000001, '1000001 Filler ...'), (1000002, '1000002 Filler ...')", @@ -987,5 +987,561 @@ "Res": null } ] - } + }, + { + "Name": "TestRangePartitionBoundariesNe", + "Cases": [ + { + "SQL": "INSERT INTO t VALUES (0, '0 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (1, '1 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (2, '2 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (3, '3 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (4, '4 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (5, '5 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "INSERT INTO t VALUES (6, '6 Filler...')", + "Plan": [ + "Insert N/A root N/A" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a != -1", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1", + "Plan": [ + "TableReader 10.00 root partition:p0 data:Selection", + "└─Selection 10.00 cop[tikv] or(0, eq(testrangepartitionboundariesne.t.a, -1))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a != 0", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 0)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0", + "Plan": [ + "TableReader 20.00 root partition:p0 data:Selection", + "└─Selection 20.00 cop[tikv] or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0)))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 1", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 1)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1", + "Plan": [ + "TableReader 30.00 root partition:p0,p1 data:Selection", + "└─Selection 30.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1)))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 2", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 2)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2", + "Plan": [ + "TableReader 40.00 root partition:p0,p1,p2 data:Selection", + "└─Selection 40.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2))))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 3", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 3)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3", + "Plan": [ + "TableReader 50.00 root partition:p0,p1,p2,p3 data:Selection", + "└─Selection 50.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(eq(testrangepartitionboundariesne.t.a, 1), or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3))))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 4", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 4)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4", + "Plan": [ + "TableReader 60.00 root partition:p0,p1,p2,p3,p4 data:Selection", + "└─Selection 60.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)), or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4))))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 5", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 5)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5", + "Plan": [ + "TableReader 70.00 root partition:p0,p1,p2,p3,p4,p5 data:Selection", + "└─Selection 70.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), eq(testrangepartitionboundariesne.t.a, 5))))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 6", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 6)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6", + "Plan": [ + "TableReader 80.00 root partition:all data:Selection", + "└─Selection 80.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), or(eq(testrangepartitionboundariesne.t.a, 5), eq(testrangepartitionboundariesne.t.a, 6)))))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE a != 7", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 7)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6 AND a != 7", + "Plan": [ + "TableReader 6656.67 root partition:all data:Selection", + "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6), ne(testrangepartitionboundariesne.t.a, 7)", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6, 7)", + "Plan": [ + "TableReader 3583.33 root partition:all data:Selection", + "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": null + }, + { + "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6 OR a = 7", + "Plan": [ + "TableReader 90.00 root partition:all data:Selection", + "└─Selection 90.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)))), or(or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4)), or(eq(testrangepartitionboundariesne.t.a, 5), or(eq(testrangepartitionboundariesne.t.a, 6), eq(testrangepartitionboundariesne.t.a, 7)))))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ], + "Res": [ + "0 0 Filler...", + "1 1 Filler...", + "2 2 Filler...", + "3 3 Filler...", + "4 4 Filler...", + "5 5 Filler...", + "6 6 Filler..." + ] + } + ] + } ] From a46f215081bb637c3694a16a36fbfcaa497fe473 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 12 May 2021 16:45:22 +0200 Subject: [PATCH 3/7] partition range boundaries EQ, IN, NE, minor test case fix Moved cleanup from end of test to 'defer' for more go-like coding style, as suggested by reviewer. --- 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 dd7566ef2892b..5f435283643d9 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -678,6 +678,7 @@ func (s *testSuiteWithData) TestRangePartitionBoundariesEq(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("create database TestRangePartitionBoundaries") + defer tk.MustExec("drop database TestRangePartitionBoundaries") tk.MustExec("use TestRangePartitionBoundaries") tk.MustExec(`CREATE TABLE t (a INT, b varchar(255)) @@ -712,13 +713,13 @@ PARTITION BY RANGE (a) ( tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) } - tk.MustExec("drop database TestRangePartitionBoundaries") } func (s *testSuiteWithData) TestRangePartitionBoundariesNe(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("create database TestRangePartitionBoundariesNe") + defer tk.MustExec("drop database TestRangePartitionBoundariesNe") tk.MustExec("use TestRangePartitionBoundariesNe") tk.MustExec(`CREATE TABLE t (a INT, b varchar(255)) @@ -756,5 +757,4 @@ PARTITION BY RANGE (a) ( tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) } - tk.MustExec("drop database TestRangePartitionBoundariesNe") } From 171d94bc3ed67be5180b0bb4c940fdf27305b0ca Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 17 May 2021 00:48:25 +0200 Subject: [PATCH 4/7] minor updates to test, drop if exists and setting dynamic pruning --- executor/partition_table_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 5f435283643d9..40dd7562a6eac 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -677,9 +677,11 @@ func (s *globalIndexSuite) TestIssue21731(c *C) { func (s *testSuiteWithData) TestRangePartitionBoundariesEq(c *C) { tk := testkit.NewTestKit(c, s.store) + tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") tk.MustExec("create database TestRangePartitionBoundaries") defer tk.MustExec("drop database TestRangePartitionBoundaries") tk.MustExec("use TestRangePartitionBoundaries") + tk.MustExec("DROP TABLE IF EXISTS t") tk.MustExec(`CREATE TABLE t (a INT, b varchar(255)) PARTITION BY RANGE (a) ( @@ -718,9 +720,11 @@ PARTITION BY RANGE (a) ( func (s *testSuiteWithData) TestRangePartitionBoundariesNe(c *C) { tk := testkit.NewTestKit(c, s.store) + tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") tk.MustExec("create database TestRangePartitionBoundariesNe") defer tk.MustExec("drop database TestRangePartitionBoundariesNe") tk.MustExec("use TestRangePartitionBoundariesNe") + tk.MustExec("DROP TABLE IF EXISTS t") tk.MustExec(`CREATE TABLE t (a INT, b varchar(255)) PARTITION BY RANGE (a) ( From b09b8c728cab2810721be430eb693137c2f2e2d4 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 17 May 2021 01:11:21 +0200 Subject: [PATCH 5/7] Adjusted tests according to review comments. Added ANALYZE TABLE before querying the table for more stable testing. Needed to a positive check for SELECT instead of INSERT to only check EXPLAIN for SELECT queries. --- executor/partition_table_test.go | 54 +-- executor/testdata/executor_suite_in.json | 2 + executor/testdata/executor_suite_out.json | 462 +++++++++++----------- 3 files changed, 257 insertions(+), 261 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index 40dd7562a6eac..cdedbec777832 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -677,10 +677,10 @@ func (s *globalIndexSuite) TestIssue21731(c *C) { func (s *testSuiteWithData) TestRangePartitionBoundariesEq(c *C) { tk := testkit.NewTestKit(c, s.store) - tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") - tk.MustExec("create database TestRangePartitionBoundaries") - defer tk.MustExec("drop database TestRangePartitionBoundaries") - tk.MustExec("use TestRangePartitionBoundaries") + tk.MustExec("SET @@tidb_partition_prune_mode = 'dynamic'") + tk.MustExec("CREATE DATABASE TestRangePartitionBoundaries") + defer tk.MustExec("DROP DATABASE TestRangePartitionBoundaries") + tk.MustExec("USE TestRangePartitionBoundaries") tk.MustExec("DROP TABLE IF EXISTS t") tk.MustExec(`CREATE TABLE t (a INT, b varchar(255)) @@ -698,21 +698,24 @@ PARTITION BY RANGE (a) ( } s.testData.GetTestCases(c, &input, &output) for i, tt := range input { - var isInsert bool = false - if strings.HasPrefix(strings.ToLower(tt), "insert ") { - isInsert = true + var isSelect bool = false + if strings.HasPrefix(strings.ToLower(tt), "select ") { + isSelect = true } s.testData.OnRecord(func() { output[i].SQL = tt - output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("explain format = 'brief' " + tt).Rows()) - if isInsert { + if isSelect { + output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Rows()) + output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) + } else { // to avoid double execution of INSERT (and INSERT does not return anything) output[i].Res = nil - } else { - output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) + output[i].Plan = nil } }) - tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + if isSelect { + tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + } tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) } } @@ -720,10 +723,10 @@ PARTITION BY RANGE (a) ( func (s *testSuiteWithData) TestRangePartitionBoundariesNe(c *C) { tk := testkit.NewTestKit(c, s.store) - tk.MustExec("set @@tidb_partition_prune_mode = 'dynamic'") - tk.MustExec("create database TestRangePartitionBoundariesNe") - defer tk.MustExec("drop database TestRangePartitionBoundariesNe") - tk.MustExec("use TestRangePartitionBoundariesNe") + tk.MustExec("SET @@tidb_partition_prune_mode = 'dynamic'") + tk.MustExec("CREATE DATABASE TestRangePartitionBoundariesNe") + defer tk.MustExec("DROP DATABASE TestRangePartitionBoundariesNe") + tk.MustExec("USE TestRangePartitionBoundariesNe") tk.MustExec("DROP TABLE IF EXISTS t") tk.MustExec(`CREATE TABLE t (a INT, b varchar(255)) @@ -744,21 +747,24 @@ PARTITION BY RANGE (a) ( } s.testData.GetTestCases(c, &input, &output) for i, tt := range input { - var isInsert bool = false - if strings.HasPrefix(strings.ToLower(tt), "insert ") { - isInsert = true + var isSelect bool = false + if strings.HasPrefix(strings.ToLower(tt), "select ") { + isSelect = true } s.testData.OnRecord(func() { output[i].SQL = tt - output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("explain format = 'brief' " + tt).Rows()) - if isInsert { + if isSelect { + output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Rows()) + output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) + } else { // to avoid double execution of INSERT (and INSERT does not return anything) output[i].Res = nil - } else { - output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) + output[i].Plan = nil } }) - tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + if isSelect { + tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + } tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) } } diff --git a/executor/testdata/executor_suite_in.json b/executor/testdata/executor_suite_in.json index 77f311b3f3b0e..fff3187717f0a 100644 --- a/executor/testdata/executor_suite_in.json +++ b/executor/testdata/executor_suite_in.json @@ -59,6 +59,7 @@ "INSERT INTO t VALUES (1999998, '1999998 Filler ...'), (1999999, '1999999 Filler ...'), (2000000, '2000000 Filler ...'), (2000001, '2000001 Filler ...'), (2000002, '2000002 Filler ...')", "INSERT INTO t VALUES (2999998, '2999998 Filler ...'), (2999999, '2999999 Filler ...')", "INSERT INTO t VALUES (-2147483648, 'MIN_INT filler...'), (0, '0 Filler...')", + "ANALYZE TABLE t", "SELECT * FROM t WHERE a = -2147483648", "SELECT * FROM t WHERE a IN (-2147483648)", "SELECT * FROM t WHERE a = 0", @@ -103,6 +104,7 @@ "INSERT INTO t VALUES (4, '4 Filler...')", "INSERT INTO t VALUES (5, '5 Filler...')", "INSERT INTO t VALUES (6, '6 Filler...')", + "ANALYZE TABLE t", "SELECT * FROM t WHERE a != -1", "SELECT * FROM t WHERE 1 = 1 AND a != -1", "SELECT * FROM t WHERE a NOT IN (-2, -1)", diff --git a/executor/testdata/executor_suite_out.json b/executor/testdata/executor_suite_out.json index 2b1c0a6fdb2fb..754c57e645c3a 100644 --- a/executor/testdata/executor_suite_out.json +++ b/executor/testdata/executor_suite_out.json @@ -604,38 +604,35 @@ "Cases": [ { "SQL": "INSERT INTO t VALUES (999998, '999998 Filler ...'), (999999, '999999 Filler ...'), (1000000, '1000000 Filler ...'), (1000001, '1000001 Filler ...'), (1000002, '1000002 Filler ...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (1999998, '1999998 Filler ...'), (1999999, '1999999 Filler ...'), (2000000, '2000000 Filler ...'), (2000001, '2000001 Filler ...'), (2000002, '2000002 Filler ...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (2999998, '2999998 Filler ...'), (2999999, '2999999 Filler ...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (-2147483648, 'MIN_INT filler...'), (0, '0 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, + "Res": null + }, + { + "SQL": "ANALYZE TABLE t", + "Plan": null, "Res": null }, { "SQL": "SELECT * FROM t WHERE a = -2147483648", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "-2147483648 MIN_INT filler..." @@ -644,9 +641,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (-2147483648)", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "-2147483648 MIN_INT filler..." @@ -655,9 +652,9 @@ { "SQL": "SELECT * FROM t WHERE a = 0", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler..." @@ -666,9 +663,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (0)", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler..." @@ -677,9 +674,9 @@ { "SQL": "SELECT * FROM t WHERE a = 999998", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "999998 999998 Filler ..." @@ -688,9 +685,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (999998)", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "999998 999998 Filler ..." @@ -699,9 +696,9 @@ { "SQL": "SELECT * FROM t WHERE a = 999999", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "999999 999999 Filler ..." @@ -710,9 +707,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (999999)", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "999999 999999 Filler ..." @@ -721,9 +718,9 @@ { "SQL": "SELECT * FROM t WHERE a = 1000000", "Plan": [ - "TableReader 10.00 root partition:p1 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p1 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000000 1000000 Filler ..." @@ -732,9 +729,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000000)", "Plan": [ - "TableReader 10.00 root partition:p1 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p1 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000000 1000000 Filler ..." @@ -743,9 +740,9 @@ { "SQL": "SELECT * FROM t WHERE a = 1000001", "Plan": [ - "TableReader 10.00 root partition:p1 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p1 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000001 1000001 Filler ..." @@ -754,9 +751,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000001)", "Plan": [ - "TableReader 10.00 root partition:p1 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p1 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000001 1000001 Filler ..." @@ -765,9 +762,9 @@ { "SQL": "SELECT * FROM t WHERE a = 1000002", "Plan": [ - "TableReader 10.00 root partition:p1 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p1 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000002 1000002 Filler ..." @@ -776,9 +773,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000002)", "Plan": [ - "TableReader 10.00 root partition:p1 data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p1 data:Selection", + "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000002 1000002 Filler ..." @@ -787,45 +784,45 @@ { "SQL": "SELECT * FROM t WHERE a = 3000000", "Plan": [ - "TableReader 10.00 root partition:dual data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:dual data:Selection", + "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (3000000)", "Plan": [ - "TableReader 10.00 root partition:dual data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:dual data:Selection", + "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a = 3000001", "Plan": [ - "TableReader 10.00 root partition:dual data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:dual data:Selection", + "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (3000001)", "Plan": [ - "TableReader 10.00 root partition:dual data:Selection", - "└─Selection 10.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:dual data:Selection", + "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (-2147483648, -2147483647)", "Plan": [ - "TableReader 20.00 root partition:p0 data:Selection", - "└─Selection 20.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483648, -2147483647)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483648, -2147483647)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "-2147483648 MIN_INT filler..." @@ -834,18 +831,18 @@ { "SQL": "SELECT * FROM t WHERE a IN (-2147483647, -2147483646)", "Plan": [ - "TableReader 20.00 root partition:p0 data:Selection", - "└─Selection 20.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483647, -2147483646)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:p0 data:Selection", + "└─Selection 0.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483647, -2147483646)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (999997, 999998, 999999)", "Plan": [ - "TableReader 30.00 root partition:p0 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999997, 999998, 999999)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:p0 data:Selection", + "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999997, 999998, 999999)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "999998 999998 Filler ...", @@ -855,9 +852,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (999998, 999999, 1000000)", "Plan": [ - "TableReader 30.00 root partition:p0,p1 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999998, 999999, 1000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p0,p1 data:Selection", + "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999998, 999999, 1000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000000 1000000 Filler ...", @@ -868,9 +865,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (999999, 1000000, 1000001)", "Plan": [ - "TableReader 30.00 root partition:p0,p1 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999999, 1000000, 1000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p0,p1 data:Selection", + "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999999, 1000000, 1000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000000 1000000 Filler ...", @@ -881,9 +878,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000000, 1000001, 1000002)", "Plan": [ - "TableReader 30.00 root partition:p1 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1000000, 1000001, 1000002)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p1 data:Selection", + "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1000000, 1000001, 1000002)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1000000 1000000 Filler ...", @@ -894,9 +891,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1999997, 1999998, 1999999)", "Plan": [ - "TableReader 30.00 root partition:p1 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999997, 1999998, 1999999)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:p1 data:Selection", + "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999997, 1999998, 1999999)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1999998 1999998 Filler ...", @@ -906,9 +903,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1999998, 1999999, 2000000)", "Plan": [ - "TableReader 30.00 root partition:p1,p2 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999998, 1999999, 2000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p1,p2 data:Selection", + "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999998, 1999999, 2000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1999998 1999998 Filler ...", @@ -919,9 +916,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (1999999, 2000000, 2000001)", "Plan": [ - "TableReader 30.00 root partition:p1,p2 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999999, 2000000, 2000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p1,p2 data:Selection", + "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999999, 2000000, 2000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "1999999 1999999 Filler ...", @@ -932,9 +929,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (2000000, 2000001, 2000002)", "Plan": [ - "TableReader 30.00 root partition:p2 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2000000, 2000001, 2000002)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p2 data:Selection", + "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2000000, 2000001, 2000002)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "2000000 2000000 Filler ...", @@ -945,9 +942,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (2999997, 2999998, 2999999)", "Plan": [ - "TableReader 30.00 root partition:p2 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999997, 2999998, 2999999)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:p2 data:Selection", + "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999997, 2999998, 2999999)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "2999998 2999998 Filler ...", @@ -957,9 +954,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (2999998, 2999999, 3000000)", "Plan": [ - "TableReader 30.00 root partition:p2 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999998, 2999999, 3000000)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:p2 data:Selection", + "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999998, 2999999, 3000000)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "2999998 2999998 Filler ...", @@ -969,9 +966,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (2999999, 3000000, 3000001)", "Plan": [ - "TableReader 30.00 root partition:p2 data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999999, 3000000, 3000001)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p2 data:Selection", + "└─Selection 1.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999999, 3000000, 3000001)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": [ "2999999 2999999 Filler ..." @@ -980,9 +977,9 @@ { "SQL": "SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002)", "Plan": [ - "TableReader 30.00 root partition:dual data:Selection", - "└─Selection 30.00 cop[tikv] in(testrangepartitionboundaries.t.a, 3000000, 3000001, 3000002)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:dual data:Selection", + "└─Selection 0.00 cop[tikv] in(testrangepartitionboundaries.t.a, 3000000, 3000001, 3000002)", + " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" ], "Res": null } @@ -993,59 +990,50 @@ "Cases": [ { "SQL": "INSERT INTO t VALUES (0, '0 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (1, '1 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (2, '2 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (3, '3 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (4, '4 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (5, '5 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, "Res": null }, { "SQL": "INSERT INTO t VALUES (6, '6 Filler...')", - "Plan": [ - "Insert N/A root N/A" - ], + "Plan": null, + "Res": null + }, + { + "SQL": "ANALYZE TABLE t", + "Plan": null, "Res": null }, { "SQL": "SELECT * FROM t WHERE a != -1", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 7.00 root partition:all data:Selection", + "└─Selection 7.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1060,9 +1048,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 7.00 root partition:all data:Selection", + "└─Selection 7.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1077,9 +1065,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 7.00 root partition:all data:Selection", + "└─Selection 7.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1094,18 +1082,18 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1", "Plan": [ - "TableReader 10.00 root partition:p0 data:Selection", - "└─Selection 10.00 cop[tikv] or(0, eq(testrangepartitionboundariesne.t.a, -1))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:p0 data:Selection", + "└─Selection 0.00 cop[tikv] or(0, eq(testrangepartitionboundariesne.t.a, -1))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a != 0", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 0)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 0)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "1 1 Filler...", @@ -1119,9 +1107,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "1 1 Filler...", @@ -1135,9 +1123,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "1 1 Filler...", @@ -1151,9 +1139,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0", "Plan": [ - "TableReader 20.00 root partition:p0 data:Selection", - "└─Selection 20.00 cop[tikv] or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0)))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:p0 data:Selection", + "└─Selection 1.00 cop[tikv] or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0)))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler..." @@ -1162,9 +1150,9 @@ { "SQL": "SELECT * FROM t WHERE a != 1", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 1)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 1)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1178,9 +1166,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 5.00 root partition:all data:Selection", + "└─Selection 5.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "2 2 Filler...", @@ -1193,9 +1181,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 5.00 root partition:all data:Selection", + "└─Selection 5.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "2 2 Filler...", @@ -1208,9 +1196,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1", "Plan": [ - "TableReader 30.00 root partition:p0,p1 data:Selection", - "└─Selection 30.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1)))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:p0,p1 data:Selection", + "└─Selection 2.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1)))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1220,9 +1208,9 @@ { "SQL": "SELECT * FROM t WHERE a != 2", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 2)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 2)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1236,9 +1224,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 4.00 root partition:all data:Selection", + "└─Selection 4.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "3 3 Filler...", @@ -1250,9 +1238,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 4.00 root partition:all data:Selection", + "└─Selection 4.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "3 3 Filler...", @@ -1264,9 +1252,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2", "Plan": [ - "TableReader 40.00 root partition:p0,p1,p2 data:Selection", - "└─Selection 40.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2))))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:p0,p1,p2 data:Selection", + "└─Selection 3.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2))))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1277,9 +1265,9 @@ { "SQL": "SELECT * FROM t WHERE a != 3", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 3)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 3)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1293,9 +1281,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:all data:Selection", + "└─Selection 3.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "4 4 Filler...", @@ -1306,9 +1294,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 3.00 root partition:all data:Selection", + "└─Selection 3.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "4 4 Filler...", @@ -1319,9 +1307,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3", "Plan": [ - "TableReader 50.00 root partition:p0,p1,p2,p3 data:Selection", - "└─Selection 50.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(eq(testrangepartitionboundariesne.t.a, 1), or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3))))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 4.00 root partition:p0,p1,p2,p3 data:Selection", + "└─Selection 4.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(eq(testrangepartitionboundariesne.t.a, 1), or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3))))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1333,9 +1321,9 @@ { "SQL": "SELECT * FROM t WHERE a != 4", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 4)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 4)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1349,9 +1337,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:all data:Selection", + "└─Selection 2.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "5 5 Filler...", @@ -1361,9 +1349,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 2.00 root partition:all data:Selection", + "└─Selection 2.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "5 5 Filler...", @@ -1373,9 +1361,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4", "Plan": [ - "TableReader 60.00 root partition:p0,p1,p2,p3,p4 data:Selection", - "└─Selection 60.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)), or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4))))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 5.00 root partition:p0,p1,p2,p3,p4 data:Selection", + "└─Selection 5.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)), or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4))))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1388,9 +1376,9 @@ { "SQL": "SELECT * FROM t WHERE a != 5", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 5)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 5)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1404,9 +1392,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:all data:Selection", + "└─Selection 1.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "6 6 Filler..." @@ -1415,9 +1403,9 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 1.00 root partition:all data:Selection", + "└─Selection 1.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "6 6 Filler..." @@ -1426,9 +1414,9 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5", "Plan": [ - "TableReader 70.00 root partition:p0,p1,p2,p3,p4,p5 data:Selection", - "└─Selection 70.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), eq(testrangepartitionboundariesne.t.a, 5))))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:p0,p1,p2,p3,p4,p5 data:Selection", + "└─Selection 6.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), eq(testrangepartitionboundariesne.t.a, 5))))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1442,9 +1430,9 @@ { "SQL": "SELECT * FROM t WHERE a != 6", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 6)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 6.00 root partition:all data:Selection", + "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 6)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1458,27 +1446,27 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:all data:Selection", + "└─Selection 0.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:all data:Selection", + "└─Selection 0.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6", "Plan": [ - "TableReader 80.00 root partition:all data:Selection", - "└─Selection 80.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), or(eq(testrangepartitionboundariesne.t.a, 5), eq(testrangepartitionboundariesne.t.a, 6)))))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 7.00 root partition:all data:Selection", + "└─Selection 7.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), or(eq(testrangepartitionboundariesne.t.a, 5), eq(testrangepartitionboundariesne.t.a, 6)))))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1493,9 +1481,9 @@ { "SQL": "SELECT * FROM t WHERE a != 7", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, 7)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 7.00 root partition:all data:Selection", + "└─Selection 7.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 7)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", @@ -1510,27 +1498,27 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6 AND a != 7", "Plan": [ - "TableReader 6656.67 root partition:all data:Selection", - "└─Selection 6656.67 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6), ne(testrangepartitionboundariesne.t.a, 7)", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:all data:Selection", + "└─Selection 0.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6), ne(testrangepartitionboundariesne.t.a, 7)", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6, 7)", "Plan": [ - "TableReader 3583.33 root partition:all data:Selection", - "└─Selection 3583.33 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 0.00 root partition:all data:Selection", + "└─Selection 0.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6 OR a = 7", "Plan": [ - "TableReader 90.00 root partition:all data:Selection", - "└─Selection 90.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)))), or(or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4)), or(eq(testrangepartitionboundariesne.t.a, 5), or(eq(testrangepartitionboundariesne.t.a, 6), eq(testrangepartitionboundariesne.t.a, 7)))))", - " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader 7.00 root partition:all data:Selection", + "└─Selection 7.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)))), or(or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4)), or(eq(testrangepartitionboundariesne.t.a, 5), or(eq(testrangepartitionboundariesne.t.a, 6), eq(testrangepartitionboundariesne.t.a, 7)))))", + " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" ], "Res": [ "0 0 Filler...", From 89df0298177a56376afaf0230aeb5935d9c05537 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 18 May 2021 14:55:39 +0200 Subject: [PATCH 6/7] add correctness tests for range partitioning boundaries Changed the test to only output the used (non-pruned) partitions to make it easier to focus on the result and more stable accross changes in the planner/optimizer. --- executor/partition_table_test.go | 48 ++-- executor/testdata/executor_suite_out.json | 272 ++++++---------------- util/testkit/testkit.go | 15 ++ 3 files changed, 98 insertions(+), 237 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index cdedbec777832..8896806900ff7 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -691,33 +691,15 @@ PARTITION BY RANGE (a) ( `) var input []string - var output []struct { - SQL string - Plan []string - Res []string - } + var output []testOutput s.testData.GetTestCases(c, &input, &output) - for i, tt := range input { - var isSelect bool = false - if strings.HasPrefix(strings.ToLower(tt), "select ") { - isSelect = true - } - s.testData.OnRecord(func() { - output[i].SQL = tt - if isSelect { - output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Rows()) - output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) - } else { - // to avoid double execution of INSERT (and INSERT does not return anything) - output[i].Res = nil - output[i].Plan = nil - } - }) - if isSelect { - tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) - } - tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) - } + s.verifyPartitionResult(tk, input, output) +} + +type testOutput struct { + SQL string + Plan []string + Res []string } func (s *testSuiteWithData) TestRangePartitionBoundariesNe(c *C) { @@ -740,12 +722,12 @@ PARTITION BY RANGE (a) ( PARTITION p6 VALUES LESS THAN (7))`) var input []string - var output []struct { - SQL string - Plan []string - Res []string - } + var output []testOutput s.testData.GetTestCases(c, &input, &output) + s.verifyPartitionResult(tk, input, output) +} + +func (s *testSuiteWithData) verifyPartitionResult(tk *testkit.TestKit, input []string, output []testOutput) { for i, tt := range input { var isSelect bool = false if strings.HasPrefix(strings.ToLower(tt), "select ") { @@ -754,7 +736,7 @@ PARTITION BY RANGE (a) ( s.testData.OnRecord(func() { output[i].SQL = tt if isSelect { - output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Rows()) + output[i].Plan = s.testData.ConvertRowsToStrings(tk.UsedPartitions(tt).Rows()) output[i].Res = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Sort().Rows()) } else { // to avoid double execution of INSERT (and INSERT does not return anything) @@ -763,7 +745,7 @@ PARTITION BY RANGE (a) ( } }) if isSelect { - tk.MustQuery("EXPLAIN FORMAT = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...)) + tk.UsedPartitions(tt).Check(testkit.Rows(output[i].Plan...)) } tk.MayQuery(tt).Sort().Check(testkit.Rows(output[i].Res...)) } diff --git a/executor/testdata/executor_suite_out.json b/executor/testdata/executor_suite_out.json index 754c57e645c3a..caa5c4f948966 100644 --- a/executor/testdata/executor_suite_out.json +++ b/executor/testdata/executor_suite_out.json @@ -630,9 +630,7 @@ { "SQL": "SELECT * FROM t WHERE a = -2147483648", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "-2147483648 MIN_INT filler..." @@ -641,9 +639,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (-2147483648)", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, -2147483648)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "-2147483648 MIN_INT filler..." @@ -652,9 +648,7 @@ { "SQL": "SELECT * FROM t WHERE a = 0", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "0 0 Filler..." @@ -663,9 +657,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (0)", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 0)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "0 0 Filler..." @@ -674,9 +666,7 @@ { "SQL": "SELECT * FROM t WHERE a = 999998", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "999998 999998 Filler ..." @@ -685,9 +675,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (999998)", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999998)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "999998 999998 Filler ..." @@ -696,9 +684,7 @@ { "SQL": "SELECT * FROM t WHERE a = 999999", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "999999 999999 Filler ..." @@ -707,9 +693,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (999999)", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 999999)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "999999 999999 Filler ..." @@ -718,9 +702,7 @@ { "SQL": "SELECT * FROM t WHERE a = 1000000", "Plan": [ - "TableReader 1.00 root partition:p1 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000000 1000000 Filler ..." @@ -729,9 +711,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000000)", "Plan": [ - "TableReader 1.00 root partition:p1 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000000 1000000 Filler ..." @@ -740,9 +720,7 @@ { "SQL": "SELECT * FROM t WHERE a = 1000001", "Plan": [ - "TableReader 1.00 root partition:p1 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000001 1000001 Filler ..." @@ -751,9 +729,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000001)", "Plan": [ - "TableReader 1.00 root partition:p1 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000001 1000001 Filler ..." @@ -762,9 +738,7 @@ { "SQL": "SELECT * FROM t WHERE a = 1000002", "Plan": [ - "TableReader 1.00 root partition:p1 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000002 1000002 Filler ..." @@ -773,9 +747,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000002)", "Plan": [ - "TableReader 1.00 root partition:p1 data:Selection", - "└─Selection 1.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 1000002)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000002 1000002 Filler ..." @@ -784,45 +756,35 @@ { "SQL": "SELECT * FROM t WHERE a = 3000000", "Plan": [ - "TableReader 0.00 root partition:dual data:Selection", - "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "dual" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (3000000)", "Plan": [ - "TableReader 0.00 root partition:dual data:Selection", - "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "dual" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a = 3000001", "Plan": [ - "TableReader 0.00 root partition:dual data:Selection", - "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "dual" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (3000001)", "Plan": [ - "TableReader 0.00 root partition:dual data:Selection", - "└─Selection 0.00 cop[tikv] eq(testrangepartitionboundaries.t.a, 3000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "dual" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (-2147483648, -2147483647)", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483648, -2147483647)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "-2147483648 MIN_INT filler..." @@ -831,18 +793,14 @@ { "SQL": "SELECT * FROM t WHERE a IN (-2147483647, -2147483646)", "Plan": [ - "TableReader 0.00 root partition:p0 data:Selection", - "└─Selection 0.00 cop[tikv] in(testrangepartitionboundaries.t.a, -2147483647, -2147483646)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a IN (999997, 999998, 999999)", "Plan": [ - "TableReader 2.00 root partition:p0 data:Selection", - "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999997, 999998, 999999)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "999998 999998 Filler ...", @@ -852,9 +810,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (999998, 999999, 1000000)", "Plan": [ - "TableReader 3.00 root partition:p0,p1 data:Selection", - "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999998, 999999, 1000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0 p1" ], "Res": [ "1000000 1000000 Filler ...", @@ -865,9 +821,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (999999, 1000000, 1000001)", "Plan": [ - "TableReader 3.00 root partition:p0,p1 data:Selection", - "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 999999, 1000000, 1000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p0 p1" ], "Res": [ "1000000 1000000 Filler ...", @@ -878,9 +832,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1000000, 1000001, 1000002)", "Plan": [ - "TableReader 3.00 root partition:p1 data:Selection", - "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1000000, 1000001, 1000002)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1000000 1000000 Filler ...", @@ -891,9 +843,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1999997, 1999998, 1999999)", "Plan": [ - "TableReader 2.00 root partition:p1 data:Selection", - "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999997, 1999998, 1999999)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1" ], "Res": [ "1999998 1999998 Filler ...", @@ -903,9 +853,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1999998, 1999999, 2000000)", "Plan": [ - "TableReader 3.00 root partition:p1,p2 data:Selection", - "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999998, 1999999, 2000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1 p2" ], "Res": [ "1999998 1999998 Filler ...", @@ -916,9 +864,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (1999999, 2000000, 2000001)", "Plan": [ - "TableReader 3.00 root partition:p1,p2 data:Selection", - "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 1999999, 2000000, 2000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p1 p2" ], "Res": [ "1999999 1999999 Filler ...", @@ -929,9 +875,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (2000000, 2000001, 2000002)", "Plan": [ - "TableReader 3.00 root partition:p2 data:Selection", - "└─Selection 3.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2000000, 2000001, 2000002)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p2" ], "Res": [ "2000000 2000000 Filler ...", @@ -942,9 +886,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (2999997, 2999998, 2999999)", "Plan": [ - "TableReader 2.00 root partition:p2 data:Selection", - "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999997, 2999998, 2999999)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p2" ], "Res": [ "2999998 2999998 Filler ...", @@ -954,9 +896,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (2999998, 2999999, 3000000)", "Plan": [ - "TableReader 2.00 root partition:p2 data:Selection", - "└─Selection 2.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999998, 2999999, 3000000)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p2" ], "Res": [ "2999998 2999998 Filler ...", @@ -966,9 +906,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (2999999, 3000000, 3000001)", "Plan": [ - "TableReader 1.00 root partition:p2 data:Selection", - "└─Selection 1.00 cop[tikv] in(testrangepartitionboundaries.t.a, 2999999, 3000000, 3000001)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "p2" ], "Res": [ "2999999 2999999 Filler ..." @@ -977,9 +915,7 @@ { "SQL": "SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002)", "Plan": [ - "TableReader 0.00 root partition:dual data:Selection", - "└─Selection 0.00 cop[tikv] in(testrangepartitionboundaries.t.a, 3000000, 3000001, 3000002)", - " └─TableFullScan 14.00 cop[tikv] table:t keep order:false" + "dual" ], "Res": null } @@ -1031,9 +967,7 @@ { "SQL": "SELECT * FROM t WHERE a != -1", "Plan": [ - "TableReader 7.00 root partition:all data:Selection", - "└─Selection 7.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1048,9 +982,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1", "Plan": [ - "TableReader 7.00 root partition:all data:Selection", - "└─Selection 7.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1065,9 +997,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1)", "Plan": [ - "TableReader 7.00 root partition:all data:Selection", - "└─Selection 7.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1082,18 +1012,14 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1", "Plan": [ - "TableReader 0.00 root partition:p0 data:Selection", - "└─Selection 0.00 cop[tikv] or(0, eq(testrangepartitionboundariesne.t.a, -1))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a != 0", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 0)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "1 1 Filler...", @@ -1107,9 +1033,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "1 1 Filler...", @@ -1123,9 +1047,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0)", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "1 1 Filler...", @@ -1139,9 +1061,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0", "Plan": [ - "TableReader 1.00 root partition:p0 data:Selection", - "└─Selection 1.00 cop[tikv] or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0)))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0" ], "Res": [ "0 0 Filler..." @@ -1150,9 +1070,7 @@ { "SQL": "SELECT * FROM t WHERE a != 1", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 1)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1166,9 +1084,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1", "Plan": [ - "TableReader 5.00 root partition:all data:Selection", - "└─Selection 5.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "2 2 Filler...", @@ -1181,9 +1097,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1)", "Plan": [ - "TableReader 5.00 root partition:all data:Selection", - "└─Selection 5.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "2 2 Filler...", @@ -1196,9 +1110,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1", "Plan": [ - "TableReader 2.00 root partition:p0,p1 data:Selection", - "└─Selection 2.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1)))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0 p1" ], "Res": [ "0 0 Filler...", @@ -1208,9 +1120,7 @@ { "SQL": "SELECT * FROM t WHERE a != 2", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 2)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1224,9 +1134,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2", "Plan": [ - "TableReader 4.00 root partition:all data:Selection", - "└─Selection 4.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "3 3 Filler...", @@ -1238,9 +1146,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2)", "Plan": [ - "TableReader 4.00 root partition:all data:Selection", - "└─Selection 4.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "3 3 Filler...", @@ -1252,9 +1158,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2", "Plan": [ - "TableReader 3.00 root partition:p0,p1,p2 data:Selection", - "└─Selection 3.00 cop[tikv] or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2))))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0 p1 p2" ], "Res": [ "0 0 Filler...", @@ -1265,9 +1169,7 @@ { "SQL": "SELECT * FROM t WHERE a != 3", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 3)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1281,9 +1183,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3", "Plan": [ - "TableReader 3.00 root partition:all data:Selection", - "└─Selection 3.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "4 4 Filler...", @@ -1294,9 +1194,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3)", "Plan": [ - "TableReader 3.00 root partition:all data:Selection", - "└─Selection 3.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "4 4 Filler...", @@ -1307,9 +1205,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3", "Plan": [ - "TableReader 4.00 root partition:p0,p1,p2,p3 data:Selection", - "└─Selection 4.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(eq(testrangepartitionboundariesne.t.a, 1), or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3))))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0 p1 p2 p3" ], "Res": [ "0 0 Filler...", @@ -1321,9 +1217,7 @@ { "SQL": "SELECT * FROM t WHERE a != 4", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 4)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1337,9 +1231,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4", "Plan": [ - "TableReader 2.00 root partition:all data:Selection", - "└─Selection 2.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "5 5 Filler...", @@ -1349,9 +1241,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4)", "Plan": [ - "TableReader 2.00 root partition:all data:Selection", - "└─Selection 2.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "5 5 Filler...", @@ -1361,9 +1251,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4", "Plan": [ - "TableReader 5.00 root partition:p0,p1,p2,p3,p4 data:Selection", - "└─Selection 5.00 cop[tikv] or(or(0, or(eq(testrangepartitionboundariesne.t.a, -1), eq(testrangepartitionboundariesne.t.a, 0))), or(or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)), or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4))))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0 p1 p2 p3 p4" ], "Res": [ "0 0 Filler...", @@ -1376,9 +1264,7 @@ { "SQL": "SELECT * FROM t WHERE a != 5", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 5)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1392,9 +1278,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5", "Plan": [ - "TableReader 1.00 root partition:all data:Selection", - "└─Selection 1.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "6 6 Filler..." @@ -1403,9 +1287,7 @@ { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5)", "Plan": [ - "TableReader 1.00 root partition:all data:Selection", - "└─Selection 1.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "6 6 Filler..." @@ -1414,9 +1296,7 @@ { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5", "Plan": [ - "TableReader 6.00 root partition:p0,p1,p2,p3,p4,p5 data:Selection", - "└─Selection 6.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), eq(testrangepartitionboundariesne.t.a, 5))))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "p0 p1 p2 p3 p4 p5" ], "Res": [ "0 0 Filler...", @@ -1430,9 +1310,7 @@ { "SQL": "SELECT * FROM t WHERE a != 6", "Plan": [ - "TableReader 6.00 root partition:all data:Selection", - "└─Selection 6.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 6)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1446,27 +1324,21 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6", "Plan": [ - "TableReader 0.00 root partition:all data:Selection", - "└─Selection 0.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6)", "Plan": [ - "TableReader 0.00 root partition:all data:Selection", - "└─Selection 0.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6", "Plan": [ - "TableReader 7.00 root partition:all data:Selection", - "└─Selection 7.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), eq(testrangepartitionboundariesne.t.a, 1))), or(or(eq(testrangepartitionboundariesne.t.a, 2), eq(testrangepartitionboundariesne.t.a, 3)), or(eq(testrangepartitionboundariesne.t.a, 4), or(eq(testrangepartitionboundariesne.t.a, 5), eq(testrangepartitionboundariesne.t.a, 6)))))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1481,9 +1353,7 @@ { "SQL": "SELECT * FROM t WHERE a != 7", "Plan": [ - "TableReader 7.00 root partition:all data:Selection", - "└─Selection 7.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, 7)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", @@ -1498,27 +1368,21 @@ { "SQL": "SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6 AND a != 7", "Plan": [ - "TableReader 0.00 root partition:all data:Selection", - "└─Selection 0.00 cop[tikv] ne(testrangepartitionboundariesne.t.a, -1), ne(testrangepartitionboundariesne.t.a, 0), ne(testrangepartitionboundariesne.t.a, 1), ne(testrangepartitionboundariesne.t.a, 2), ne(testrangepartitionboundariesne.t.a, 3), ne(testrangepartitionboundariesne.t.a, 4), ne(testrangepartitionboundariesne.t.a, 5), ne(testrangepartitionboundariesne.t.a, 6), ne(testrangepartitionboundariesne.t.a, 7)", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6, 7)", "Plan": [ - "TableReader 0.00 root partition:all data:Selection", - "└─Selection 0.00 cop[tikv] not(in(testrangepartitionboundariesne.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": null }, { "SQL": "SELECT * FROM t WHERE 1 = 0 OR a = -1 OR a = 0 OR a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6 OR a = 7", "Plan": [ - "TableReader 7.00 root partition:all data:Selection", - "└─Selection 7.00 cop[tikv] or(or(or(0, eq(testrangepartitionboundariesne.t.a, -1)), or(eq(testrangepartitionboundariesne.t.a, 0), or(eq(testrangepartitionboundariesne.t.a, 1), eq(testrangepartitionboundariesne.t.a, 2)))), or(or(eq(testrangepartitionboundariesne.t.a, 3), eq(testrangepartitionboundariesne.t.a, 4)), or(eq(testrangepartitionboundariesne.t.a, 5), or(eq(testrangepartitionboundariesne.t.a, 6), eq(testrangepartitionboundariesne.t.a, 7)))))", - " └─TableFullScan 7.00 cop[tikv] table:t keep order:false" + "all" ], "Res": [ "0 0 Filler...", diff --git a/util/testkit/testkit.go b/util/testkit/testkit.go index 12dd811e20fe0..c9063d626829c 100644 --- a/util/testkit/testkit.go +++ b/util/testkit/testkit.go @@ -266,6 +266,21 @@ func (tk *TestKit) MustPartition(sql string, partitions string, args ...interfac return false } +// MustPartition checks if the result execution plan must read specific partitions. +func (tk *TestKit) UsedPartitions(sql string, args ...interface{}) *Result { + rs := tk.MustQuery("explain "+sql, args...) + var usedPartitions [][]string + for i := range rs.rows { + index := strings.Index(rs.rows[i][3], "partition:") + if index != -1 { + p := rs.rows[i][3][index+len("partition:"):] + partitions := strings.Split(strings.SplitN(p, " ", 2)[0], ",") + usedPartitions = append(usedPartitions, partitions) + } + } + return &Result{rows: usedPartitions, c: tk.c, comment: check.Commentf("sql:%s, args:%v", sql, args)} +} + // MustUseIndex checks if the result execution plan contains specific index(es). func (tk *TestKit) MustUseIndex(sql string, index string, args ...interface{}) bool { rs := tk.MustQuery("explain "+sql, args...) From fca1a1cf430b6cdfc36f162d9108e3304c4aa39f Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 19 May 2021 00:25:03 +0200 Subject: [PATCH 7/7] Updated test comment to fix ci/check_dev. --- util/testkit/testkit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/testkit/testkit.go b/util/testkit/testkit.go index c9063d626829c..758a284f0b007 100644 --- a/util/testkit/testkit.go +++ b/util/testkit/testkit.go @@ -266,7 +266,7 @@ func (tk *TestKit) MustPartition(sql string, partitions string, args ...interfac return false } -// MustPartition checks if the result execution plan must read specific partitions. +// UsedPartitions returns the partition names that will be used or all/dual. func (tk *TestKit) UsedPartitions(sql string, args ...interface{}) *Result { rs := tk.MustQuery("explain "+sql, args...) var usedPartitions [][]string