diff --git a/cmd/explaintest/r/partition_pruning.result b/cmd/explaintest/r/partition_pruning.result deleted file mode 100644 index 2e7d5dfcf0989..0000000000000 --- a/cmd/explaintest/r/partition_pruning.result +++ /dev/null @@ -1,2563 +0,0 @@ -set @@session.tidb_enable_table_partition=1; -drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; -# -# Bug#53806: Wrong estimates for range query in partitioned MyISAM table -# Bug#46754: 'rows' field doesn't reflect partition pruning -# -CREATE TABLE t1 (a INT PRIMARY KEY) -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 max VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,1], keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE a < 7; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,7), keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,1], keep order:false, stats:pseudo -DROP TABLE t1; -# -# Bug#49742: Partition Pruning not working correctly for RANGE -# -CREATE TABLE t1 (a INT PRIMARY KEY) -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 max VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); -SELECT * FROM t1 WHERE a < 1 order by a; -a --1 -0 -explain format = 'brief' SELECT * FROM t1 WHERE a < 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p0 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,1), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 2 order by a; -a --1 -0 -1 -explain format = 'brief' SELECT * FROM t1 WHERE a < 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,2), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 3 order by a; -a --1 -0 -1 -2 -explain format = 'brief' SELECT * FROM t1 WHERE a < 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,3), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 4 order by a; -a --1 -0 -1 -2 -3 -explain format = 'brief' SELECT * FROM t1 WHERE a < 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,4), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 5 order by a; -a --1 -0 -1 -2 -3 -4 -explain format = 'brief' SELECT * FROM t1 WHERE a < 5; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3,p4 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,5), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 6 order by a; -a --1 -0 -1 -2 -3 -4 -5 -explain format = 'brief' SELECT * FROM t1 WHERE a < 6; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3,p4,p5 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,6), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 7 order by a; -a --1 -0 -1 -2 -3 -4 -5 -6 -explain format = 'brief' SELECT * FROM t1 WHERE a < 7; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,7), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 1 order by a; -a --1 -0 -1 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,1], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 2 order by a; -a --1 -0 -1 -2 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,2], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 3 order by a; -a --1 -0 -1 -2 -3 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,3], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 4 order by a; -a --1 -0 -1 -2 -3 -4 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3,p4 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,4], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 5 order by a; -a --1 -0 -1 -2 -3 -4 -5 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 5; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3,p4,p5 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,5], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 6 order by a; -a --1 -0 -1 -2 -3 -4 -5 -6 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 6; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,6], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 7 order by a; -a --1 -0 -1 -2 -3 -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 7; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,7], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a = 1 order by a; -a -1 -explain format = 'brief' SELECT * FROM t1 WHERE a = 1; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p1 handle:1 -SELECT * FROM t1 WHERE a = 2 order by a; -a -2 -explain format = 'brief' SELECT * FROM t1 WHERE a = 2; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p2 handle:2 -SELECT * FROM t1 WHERE a = 3 order by a; -a -3 -explain format = 'brief' SELECT * FROM t1 WHERE a = 3; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p3 handle:3 -SELECT * FROM t1 WHERE a = 4 order by a; -a -4 -explain format = 'brief' SELECT * FROM t1 WHERE a = 4; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p4 handle:4 -SELECT * FROM t1 WHERE a = 5 order by a; -a -5 -explain format = 'brief' SELECT * FROM t1 WHERE a = 5; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p5 handle:5 -SELECT * FROM t1 WHERE a = 6 order by a; -a -6 -explain format = 'brief' SELECT * FROM t1 WHERE a = 6; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:max handle:6 -SELECT * FROM t1 WHERE a = 7 order by a; -a -7 -explain format = 'brief' SELECT * FROM t1 WHERE a = 7; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:max handle:7 -SELECT * FROM t1 WHERE a >= 1 order by a; -a -1 -2 -3 -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p1,p2,p3,p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[1,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 2 order by a; -a -2 -3 -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p2,p3,p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[2,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 3 order by a; -a -3 -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p3,p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[3,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 4 order by a; -a -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[4,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 5 order by a; -a -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 5; -id estRows task access object operator info -TableReader 3333.33 root partition:p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[5,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 6 order by a; -a -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 6; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[6,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 7 order by a; -a -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 7; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[7,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 1 order by a; -a -2 -3 -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p2,p3,p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(1,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 2 order by a; -a -3 -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p3,p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(2,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 3 order by a; -a -4 -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p4,p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(3,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 4 order by a; -a -5 -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p5,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(4,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 5 order by a; -a -6 -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 5; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(5,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 6 order by a; -a -7 -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 6; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(6,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 7 order by a; -a -8 -explain format = 'brief' SELECT * FROM t1 WHERE a > 7; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(7,+inf], keep order:false, stats:pseudo -DROP TABLE t1; -CREATE TABLE t1 (a INT PRIMARY KEY) -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 max VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7); -SELECT * FROM t1 WHERE a < 1 order by a; -a --1 -0 -explain format = 'brief' SELECT * FROM t1 WHERE a < 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p0 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,1), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 2 order by a; -a --1 -0 -1 -explain format = 'brief' SELECT * FROM t1 WHERE a < 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,2), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 3 order by a; -a --1 -0 -1 -2 -explain format = 'brief' SELECT * FROM t1 WHERE a < 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,3), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 4 order by a; -a --1 -0 -1 -2 -3 -explain format = 'brief' SELECT * FROM t1 WHERE a < 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,4), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 5 order by a; -a --1 -0 -1 -2 -3 -4 -explain format = 'brief' SELECT * FROM t1 WHERE a < 5; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3,p4 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,5), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a < 6 order by a; -a --1 -0 -1 -2 -3 -4 -5 -explain format = 'brief' SELECT * FROM t1 WHERE a < 6; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,6), keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 1 order by a; -a --1 -0 -1 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,1], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 2 order by a; -a --1 -0 -1 -2 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,2], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 3 order by a; -a --1 -0 -1 -2 -3 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,3], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 4 order by a; -a --1 -0 -1 -2 -3 -4 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p0,p1,p2,p3,p4 data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,4], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 5 order by a; -a --1 -0 -1 -2 -3 -4 -5 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 5; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,5], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a <= 6 order by a; -a --1 -0 -1 -2 -3 -4 -5 -6 -explain format = 'brief' SELECT * FROM t1 WHERE a <= 6; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[-inf,6], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a = 1; -a -1 -explain format = 'brief' SELECT * FROM t1 WHERE a = 1; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p1 handle:1 -SELECT * FROM t1 WHERE a = 2; -a -2 -explain format = 'brief' SELECT * FROM t1 WHERE a = 2; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p2 handle:2 -SELECT * FROM t1 WHERE a = 3; -a -3 -explain format = 'brief' SELECT * FROM t1 WHERE a = 3; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p3 handle:3 -SELECT * FROM t1 WHERE a = 4; -a -4 -explain format = 'brief' SELECT * FROM t1 WHERE a = 4; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:p4 handle:4 -SELECT * FROM t1 WHERE a = 5; -a -5 -explain format = 'brief' SELECT * FROM t1 WHERE a = 5; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:max handle:5 -SELECT * FROM t1 WHERE a = 6; -a -6 -explain format = 'brief' SELECT * FROM t1 WHERE a = 6; -id estRows task access object operator info -Point_Get 1.00 root table:t1, partition:max handle:6 -SELECT * FROM t1 WHERE a >= 1 order by a; -a -1 -2 -3 -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p1,p2,p3,p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[1,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 2 order by a; -a -2 -3 -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p2,p3,p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[2,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 3 order by a; -a -3 -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p3,p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[3,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 4 order by a; -a -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 4; -id estRows task access object operator info -TableReader 3333.33 root partition:p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[4,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 5 order by a; -a -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 5; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[5,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a >= 6 order by a; -a -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a >= 6; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:[6,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 1 order by a; -a -2 -3 -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a > 1; -id estRows task access object operator info -TableReader 3333.33 root partition:p2,p3,p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(1,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 2 order by a; -a -3 -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a > 2; -id estRows task access object operator info -TableReader 3333.33 root partition:p3,p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(2,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 3 order by a; -a -4 -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a > 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p4,max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(3,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 4 order by a; -a -5 -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a > 4; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(4,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 5 order by a; -a -6 -7 -explain format = 'brief' SELECT * FROM t1 WHERE a > 5; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(5,+inf], keep order:false, stats:pseudo -SELECT * FROM t1 WHERE a > 6 order by a; -a -7 -explain format = 'brief' SELECT * FROM t1 WHERE a > 6; -id estRows task access object operator info -TableReader 3333.33 root partition:max data:TableRangeScan -└─TableRangeScan 3333.33 cop[tikv] table:t1 range:(6,+inf], keep order:false, stats:pseudo -DROP TABLE t1; -# test of RANGE and index -CREATE TABLE t1 (a DATE, KEY(a)) -PARTITION BY RANGE (TO_DAYS(a)) -(PARTITION `pNULL` VALUES LESS THAN (0), -PARTITION `p0001-01-01` VALUES LESS THAN (366 + 1), -PARTITION `p1001-01-01` VALUES LESS THAN (TO_DAYS('1001-01-01') + 1), -PARTITION `p2001-01-01` VALUES LESS THAN (TO_DAYS('2001-01-01') + 1)); -SET SQL_MODE = ''; -INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'), -('1001-00-00'), ('1001-01-01'), ('1002-00-00'), ('2001-01-01'); -# test without index -ALTER TABLE t1 DROP KEY a; -DROP TABLE t1; -# Test with DATETIME column NOT NULL -CREATE TABLE t1 ( -a int(10) unsigned NOT NULL, -b DATETIME NOT NULL, -PRIMARY KEY (a, b) -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), -PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), -PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), -PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), -PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), -(1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-02 23:59:59'), -(1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), -(1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090402 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 10.00 root partition:p20090402 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090402 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -DROP TABLE t1; -# Test with DATE column NOT NULL -CREATE TABLE t1 ( -a int(10) unsigned NOT NULL, -b DATE NOT NULL, -PRIMARY KEY (a, b) -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), -PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), -PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), -PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), -PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), -(1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-03'), (2, '2009-04-03'), -(1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), -(1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 0.00 root partition:p20090402 index:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 0.00 root partition:p20090402 index:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task access object operator info -IndexReader 10.00 root partition:p20090403 index:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402,p20090403 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 0.00 root partition:p20090403 index:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3323.33 root partition:p20090401,p20090402 index:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 0.00 root partition:p20090402 index:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -IndexReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 index:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─IndexFullScan 10000.00 cop[tikv] table:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo -DROP TABLE t1; -# Test with DATETIME column NULL -CREATE TABLE t1 ( -a int(10) unsigned NOT NULL, -b DATETIME NULL -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), -PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), -PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), -PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), -PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), -(1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-02 23:59:59'), -(1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), -(1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 10.00 root partition:p20090402 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 10.00 root partition:p20090402 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 10.00 root partition:p20090402 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -DROP TABLE t1; -# Test with DATE column NULL -CREATE TABLE t1 ( -a int(10) unsigned NOT NULL, -b DATE NULL -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), -PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), -PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), -PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), -PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), -(1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-03'), (2, '2009-04-03'), -(1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), -(1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 0.00 root partition:p20090402 data:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 0.00 root partition:p20090402 data:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -id estRows task access object operator info -TableReader 10.00 root partition:p20090403 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402,p20090403 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 0.00 root partition:p20090403 data:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-03 00:00:01) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3323.33 root partition:p20090401,p20090402 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 0.00 root partition:p20090402 data:Selection -└─Selection 0.00 cop[tikv] eq(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' SELECT * FROM t1 -WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -id estRows task access object operator info -TableReader 3333.33 root partition:p20090402,p20090403,p20090404,p20090405 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.b, 2009-04-02 23:59:58) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -DROP TABLE t1; -# For better code coverage of the patch -CREATE TABLE t1 ( -a int(10) unsigned NOT NULL, -b DATE -) PARTITION BY RANGE ( TO_DAYS(b) ) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), -PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), -PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), -PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), -PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (2, NULL); -# test with an invalid date, which lead to item->null_value is set. -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-99' AS DATETIME); -id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] lt(test.t1.b, NULL) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -DROP TABLE t1; -CREATE TABLE t1 -(a INT NOT NULL AUTO_INCREMENT, -b DATETIME, -PRIMARY KEY (a,b), -KEY (b)) -PARTITION BY RANGE (to_days(b)) -(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01', -PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01', -PARTITION pX VALUES LESS THAN MAXVALUE); -SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00'; -a b -DROP TABLE t1; -create table t3 ( -a int -) -partition by range (a*1) ( -partition p0 values less than (10), -partition p1 values less than (20) -); -insert into t3 values (5),(15); -explain format = 'brief' select * from t3 where a=11; -id estRows task access object operator info -TableReader 10.00 root partition:p1 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t3.a, 11) - └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo -explain format = 'brief' select * from t3 where a=10; -id estRows task access object operator info -TableReader 10.00 root partition:p1 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t3.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo -explain format = 'brief' select * from t3 where a=20; -id estRows task access object operator info -TableReader 10.00 root partition:dual data:Selection -└─Selection 10.00 cop[tikv] eq(test.t3.a, 20) - └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo -explain format = 'brief' select * from t3 where a=30; -id estRows task access object operator info -TableReader 10.00 root partition:dual data:Selection -└─Selection 10.00 cop[tikv] eq(test.t3.a, 30) - └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo -create table t7 (a int not null) partition by RANGE(a) ( -partition p10 values less than (10), -partition p30 values less than (30), -partition p50 values less than (50), -partition p70 values less than (70), -partition p90 values less than (90) -); -insert into t7 values (10),(30),(50); -explain format = 'brief' select * from t7 where a < 5; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 5) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 9; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 9; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 9; -id estRows task access object operator info -TableReader 10.00 root partition:p10 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 9; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 9; -id estRows task access object operator info -TableReader 3333.33 root partition:p30,p50,p70,p90 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 10; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 10; -id estRows task access object operator info -TableReader 3323.33 root partition:p10,p30 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 10; -id estRows task access object operator info -TableReader 10.00 root partition:p30 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 10; -id estRows task access object operator info -TableReader 3333.33 root partition:p30,p50,p70,p90 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 10; -id estRows task access object operator info -TableReader 3333.33 root partition:p30,p50,p70,p90 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 89; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 89; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 89; -id estRows task access object operator info -TableReader 10.00 root partition:p90 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 89; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 89; -id estRows task access object operator info -TableReader 3333.33 root partition:p90 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 90; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 90; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 90; -id estRows task access object operator info -TableDual 0.00 root rows:0 -explain format = 'brief' select * from t7 where a > 90; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 90; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 91; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 91) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 11 and a < 29; -id estRows task access object operator info -TableReader 250.00 root partition:p30 data:Selection -└─Selection 250.00 cop[tikv] gt(test.t7.a, 11), lt(test.t7.a, 29) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -drop table t7; -create table t7 (a int unsigned not null) partition by RANGE(a) ( -partition p10 values less than (10), -partition p30 values less than (30), -partition p50 values less than (50), -partition p70 values less than (70), -partition p90 values less than (90) -); -insert into t7 values (10),(30),(50); -explain format = 'brief' select * from t7 where a < 5; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 5) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 9; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 9; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 9; -id estRows task access object operator info -TableReader 10.00 root partition:p10 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 9; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 9; -id estRows task access object operator info -TableReader 3333.33 root partition:p30,p50,p70,p90 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 9) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 10; -id estRows task access object operator info -TableReader 3323.33 root partition:p10 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 10; -id estRows task access object operator info -TableReader 3323.33 root partition:p10,p30 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 10; -id estRows task access object operator info -TableReader 10.00 root partition:p30 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 10; -id estRows task access object operator info -TableReader 3333.33 root partition:p30,p50,p70,p90 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 10; -id estRows task access object operator info -TableReader 3333.33 root partition:p30,p50,p70,p90 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 10) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 89; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 89; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 89; -id estRows task access object operator info -TableReader 10.00 root partition:p90 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 89; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 89; -id estRows task access object operator info -TableReader 3333.33 root partition:p90 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 89) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a < 90; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a <= 90; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] le(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a = 90; -id estRows task access object operator info -TableDual 0.00 root rows:0 -explain format = 'brief' select * from t7 where a > 90; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a >= 90; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t7.a, 90) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 91; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t7.a, 91) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -explain format = 'brief' select * from t7 where a > 11 and a < 29; -id estRows task access object operator info -TableReader 250.00 root partition:p30 data:Selection -└─Selection 250.00 cop[tikv] gt(test.t7.a, 11), lt(test.t7.a, 29) - └─TableFullScan 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo -create table t8 (a date not null) partition by RANGE(YEAR(a)) ( -partition p0 values less than (1980), -partition p1 values less than (1990), -partition p2 values less than (2000) -); -insert into t8 values ('1985-05-05'),('1995-05-05'); -explain format = 'brief' select * from t8 where a < '1980-02-02'; -id estRows task access object operator info -TableReader 3323.33 root partition:p0,p1 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t8.a, 1980-02-02 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t8 keep order:false, stats:pseudo -create table t9 (a date not null) partition by RANGE(TO_DAYS(a)) ( -partition p0 values less than (732299), -- 2004-12-19 -partition p1 values less than (732468), -- 2005-06-06 -partition p2 values less than (732664) -- 2005-12-19 -); -insert into t9 values ('2005-05-05'), ('2005-04-04'); -explain format = 'brief' select * from t9 where a < '2004-12-19'; -id estRows task access object operator info -TableReader 3323.33 root partition:p0,p1 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t9.a, 2004-12-19 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t9 keep order:false, stats:pseudo -explain format = 'brief' select * from t9 where a <= '2004-12-19'; -id estRows task access object operator info -TableReader 3323.33 root partition:p0,p1 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t9.a, 2004-12-19 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t9 keep order:false, stats:pseudo -drop table t7,t8,t9; -create table t1 ( -a1 int not null -) -partition by range (a1) ( -partition p0 values less than (3), -partition p1 values less than (6), -partition p2 values less than (9) -); -insert into t1 values (1),(2),(3); -explain format = 'brief' select * from t1 where a1 > 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p1,p2 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t1.a1, 3) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a1 >= 3; -id estRows task access object operator info -TableReader 3333.33 root partition:p1,p2 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t1.a1, 3) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a1 < 3 and a1 > 3; -id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(test.t1.a1, 3), lt(test.t1.a1, 3) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -drop table t1; -CREATE TABLE `t1` ( -`a` int(11) default NULL -); -INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -CREATE TABLE `t2` ( -`a` int(11) default NULL, -KEY `a` (`a`) -) ; -insert into t2 select A.a + 10*(B.a + 10* C.a) from t1 A, t1 B, t1 C ; -insert into t1 select a from t2; -drop table t2; -CREATE TABLE `t2` ( -`a` int(11) default NULL, -`b` int(11) default NULL -) -PARTITION BY RANGE (a) ( -PARTITION p0 VALUES LESS THAN (200), -PARTITION p1 VALUES LESS THAN (400), -PARTITION p2 VALUES LESS THAN (600), -PARTITION p3 VALUES LESS THAN (800), -PARTITION p4 VALUES LESS THAN (1001)); -insert into t2 select a,1 from t1 where a < 200; -insert into t2 select a,2 from t1 where a >= 200 and a < 400; -insert into t2 select a,3 from t1 where a >= 400 and a < 600; -insert into t2 select a,4 from t1 where a >= 600 and a < 800; -insert into t2 select a,5 from t1 where a >= 800 and a < 1001; -explain format = 'brief' select * from t2; -id estRows task access object operator info -TableReader 10000.00 root partition:all data:TableFullScan -└─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a < 801 and a > 200; -id estRows task access object operator info -TableReader 250.00 root partition:p1,p2,p3,p4 data:Selection -└─Selection 250.00 cop[tikv] gt(test.t2.a, 200), lt(test.t2.a, 801) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a < 801 and a > 800; -id estRows task access object operator info -TableReader 0.00 root partition:p4 data:Selection -└─Selection 0.00 cop[tikv] gt(test.t2.a, 800), lt(test.t2.a, 801) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a > 600; -id estRows task access object operator info -TableReader 3333.33 root partition:p3,p4 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t2.a, 600) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a > 600 and b = 1; -id estRows task access object operator info -TableReader 3.33 root partition:p3,p4 data:Selection -└─Selection 3.33 cop[tikv] eq(test.t2.b, 1), gt(test.t2.a, 600) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a > 600 and b = 4; -id estRows task access object operator info -TableReader 3.33 root partition:p3,p4 data:Selection -└─Selection 3.33 cop[tikv] eq(test.t2.b, 4), gt(test.t2.a, 600) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a > 600 and b = 5; -id estRows task access object operator info -TableReader 3.33 root partition:p3,p4 data:Selection -└─Selection 3.33 cop[tikv] eq(test.t2.b, 5), gt(test.t2.a, 600) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b = 5; -id estRows task access object operator info -TableReader 10.00 root partition:all data:Selection -└─Selection 10.00 cop[tikv] eq(test.t2.b, 5) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -flush status; -update t2 set b = 100 where b = 6; -show status like 'Handler_read_rnd_next'; -Variable_name Value -flush status; -update t2 set a = 1002 where a = 1001; -show status like 'Handler_read_rnd_next'; -Variable_name Value -flush status; -update t2 set b = 6 where a = 600; -show status like 'Handler_read_rnd_next'; -Variable_name Value -flush status; -update t2 set b = 6 where a > 600 and a < 800; -show status like 'Handler_read_rnd_next'; -Variable_name Value -flush status; -delete from t2 where a > 600; -show status like 'Handler_read_rnd_next'; -Variable_name Value -drop table t2; -CREATE TABLE `t2` ( -`a` int(11) default NULL, -`b` int(11) default NULL, -index (b) -) -PARTITION BY RANGE (a) ( -PARTITION p0 VALUES LESS THAN (200), -PARTITION p1 VALUES LESS THAN (400), -PARTITION p2 VALUES LESS THAN (600), -PARTITION p3 VALUES LESS THAN (800), -PARTITION p4 VALUES LESS THAN (1001)); -insert into t2 select a,1 from t1 where a < 100; -insert into t2 select a,2 from t1 where a >= 200 and a < 300; -insert into t2 select a,3 from t1 where a >= 300 and a < 400; -insert into t2 select a,4 from t1 where a >= 400 and a < 500; -insert into t2 select a,5 from t1 where a >= 500 and a < 600; -insert into t2 select a,6 from t1 where a >= 600 and a < 700; -insert into t2 select a,7 from t1 where a >= 700 and a < 800; -insert into t2 select a,8 from t1 where a >= 800 and a < 900; -insert into t2 select a,9 from t1 where a >= 900 and a < 1001; -explain format = 'brief' select * from t2; -id estRows task access object operator info -TableReader 10000.00 root partition:all data:TableFullScan -└─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a = 101; -id estRows task access object operator info -TableReader 10.00 root partition:p0 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t2.a, 101) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a = 550; -id estRows task access object operator info -TableReader 10.00 root partition:p2 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t2.a, 550) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a = 833; -id estRows task access object operator info -TableReader 10.00 root partition:p4 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t2.a, 833) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a in (10,20,30); -id estRows task access object operator info -TableReader 30.00 root partition:p0 data:Selection -└─Selection 30.00 cop[tikv] in(test.t2.a, 10, 20, 30) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where (a = 100 OR a = 900); -id estRows task access object operator info -TableReader 20.00 root partition:p0,p4 data:Selection -└─Selection 20.00 cop[tikv] or(eq(test.t2.a, 100), eq(test.t2.a, 900)) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where (a > 100 AND a < 600); -id estRows task access object operator info -TableReader 250.00 root partition:p0,p1,p2 data:Selection -└─Selection 250.00 cop[tikv] gt(test.t2.a, 100), lt(test.t2.a, 600) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b = 4; -id estRows task access object operator info -IndexLookUp 10.00 root partition:all -├─IndexRangeScan(Build) 10.00 cop[tikv] table:t2, index:b(b) range:[4,4], keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 10.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b = 6; -id estRows task access object operator info -IndexLookUp 10.00 root partition:all -├─IndexRangeScan(Build) 10.00 cop[tikv] table:t2, index:b(b) range:[6,6], keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 10.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b in (1,3,5); -id estRows task access object operator info -IndexLookUp 30.00 root partition:all -├─IndexRangeScan(Build) 30.00 cop[tikv] table:t2, index:b(b) range:[1,1], [3,3], [5,5], keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 30.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b in (2,4,6); -id estRows task access object operator info -IndexLookUp 30.00 root partition:all -├─IndexRangeScan(Build) 30.00 cop[tikv] table:t2, index:b(b) range:[2,2], [4,4], [6,6], keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 30.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b in (7,8,9); -id estRows task access object operator info -IndexLookUp 30.00 root partition:all -├─IndexRangeScan(Build) 30.00 cop[tikv] table:t2, index:b(b) range:[7,7], [8,8], [9,9], keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 30.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b > 5; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t2.b, 5) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b > 5 and b < 8; -id estRows task access object operator info -IndexLookUp 250.00 root partition:all -├─IndexRangeScan(Build) 250.00 cop[tikv] table:t2, index:b(b) range:(5,8), keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 250.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b > 5 and b < 7; -id estRows task access object operator info -IndexLookUp 312.50 root partition:all -├─IndexRangeScan(Build) 312.50 cop[tikv] table:t2, index:b(b) range:[6,6], keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 312.50 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where b > 0 and b < 5; -id estRows task access object operator info -IndexLookUp 250.00 root partition:all -├─IndexRangeScan(Build) 250.00 cop[tikv] table:t2, index:b(b) range:(0,5), keep order:false, stats:pseudo -└─TableRowIDScan(Probe) 250.00 cop[tikv] table:t2 keep order:false, stats:pseudo -flush status; -update t2 set a = 111 where b = 10; -show status like 'Handler_read_rnd_next'; -Variable_name Value -show status like 'Handler_read_key'; -Variable_name Value -flush status; -update t2 set a = 111 where b in (5,6); -show status like 'Handler_read_rnd_next'; -Variable_name Value -show status like 'Handler_read_key'; -Variable_name Value -flush status; -update t2 set a = 222 where b = 7; -show status like 'Handler_read_rnd_next'; -Variable_name Value -show status like 'Handler_read_key'; -Variable_name Value -flush status; -delete from t2 where b = 7; -show status like 'Handler_read_rnd_next'; -Variable_name Value -show status like 'Handler_read_key'; -Variable_name Value -flush status; -delete from t2 where b > 5; -show status like 'Handler_read_rnd_next'; -Variable_name Value -show status like 'Handler_read_key'; -Variable_name Value -show status like 'Handler_read_prev'; -Variable_name Value -show status like 'Handler_read_next'; -Variable_name Value -flush status; -delete from t2 where b < 5 or b > 3; -show status like 'Handler_read_rnd_next'; -Variable_name Value -show status like 'Handler_read_key'; -Variable_name Value -show status like 'Handler_read_prev'; -Variable_name Value -show status like 'Handler_read_next'; -Variable_name Value -drop table t1, t2; -create table t1 (s1 int); -explain format = 'brief' select 1 from t1 union all select 2; -id estRows task access object operator info -Union 10001.00 root -├─Projection 10000.00 root 1->Column#5 -│ └─TableReader 10000.00 root data:TableFullScan -│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -└─Projection 1.00 root 2->Column#5 - └─TableDual 1.00 root rows:1 -drop table t1; -create table t1 (a int) -partition by range(a) ( -partition p0 values less than (64), -partition p1 values less than (128), -partition p2 values less than (255) -); -create table t2 (a int) -partition by range(a+0) ( -partition p0 values less than (64), -partition p1 values less than (128), -partition p2 values less than (255) -); -insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); -insert into t2 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); -explain format = 'brief' select * from t1 where a=0; -id estRows task access object operator info -TableReader 10.00 root partition:p0 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.a, 0) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a=0; -id estRows task access object operator info -TableReader 10.00 root partition:p0 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t2.a, 0) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a=0xFE; -id estRows task access object operator info -TableReader 10.00 root partition:p2 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t1.a, 254) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a=0xFE; -id estRows task access object operator info -TableReader 10.00 root partition:p2 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t2.a, 254) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a > 0xFE AND a <= 0xFF; -id estRows task access object operator info -TableReader 250.00 root partition:dual data:Selection -└─Selection 250.00 cop[tikv] gt(test.t1.a, 254), le(test.t1.a, 255) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a > 0xFE AND a <= 0xFF; -id estRows task access object operator info -TableReader 250.00 root partition:dual data:Selection -└─Selection 250.00 cop[tikv] gt(test.t2.a, 254), le(test.t2.a, 255) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a >= 0xFE AND a <= 0xFF; -id estRows task access object operator info -TableReader 250.00 root partition:p2 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t1.a, 254), le(test.t1.a, 255) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a >= 0xFE AND a <= 0xFF; -id estRows task access object operator info -TableReader 250.00 root partition:p2 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t2.a, 254), le(test.t2.a, 255) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a < 64 AND a >= 63; -id estRows task access object operator info -TableReader 250.00 root partition:p0 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t1.a, 63), lt(test.t1.a, 64) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a < 64 AND a >= 63; -id estRows task access object operator info -TableReader 250.00 root partition:p0 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t2.a, 63), lt(test.t2.a, 64) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a <= 64 AND a >= 63; -id estRows task access object operator info -TableReader 250.00 root partition:p0,p1 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t1.a, 63), le(test.t1.a, 64) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t2 where a <= 64 AND a >= 63; -id estRows task access object operator info -TableReader 250.00 root partition:p0,p1 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t2.a, 63), le(test.t2.a, 64) - └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo -drop table t1; -drop table t2; -create table t1(a bigint unsigned not null) partition by range(a+0) ( -partition p1 values less than (10), -partition p2 values less than (20), -partition p3 values less than (2305561538531885056), -partition p4 values less than (2305561538531950591) -); -insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); -insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); -explain format = 'brief' select * from t1 where -a >= 2305561538531885056-10 and a <= 2305561538531885056-8; -id estRows task access object operator info -TableReader 250.00 root partition:p3 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t1.a, 2305561538531885046), le(test.t1.a, 2305561538531885048) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where -a > 0xFFFFFFFFFFFFFFEC and a < 0xFFFFFFFFFFFFFFEE; -id estRows task access object operator info -TableReader 250.00 root partition:dual data:Selection -└─Selection 250.00 cop[tikv] gt(test.t1.a, 18446744073709551596), lt(test.t1.a, 18446744073709551598) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a>=0 and a <= 0xFFFFFFFFFFFFFFFF; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] le(test.t1.a, 18446744073709551615) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -drop table t1; -create table t1 (a bigint) partition by range(a+0) ( -partition p1 values less than (-1000), -partition p2 values less than (-10), -partition p3 values less than (10), -partition p4 values less than (1000) -); -insert into t1 values (-15),(-5),(5),(15),(-15),(-5),(5),(15); -explain format = 'brief' select * from t1 where a>-2 and a <=0; -id estRows task access object operator info -TableReader 250.00 root partition:p3 data:Selection -└─Selection 250.00 cop[tikv] gt(test.t1.a, -2), le(test.t1.a, 0) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -drop table t1; -CREATE TABLE t1 ( recdate DATETIME NOT NULL ) -PARTITION BY RANGE( TO_DAYS(recdate) ) ( -PARTITION p0 VALUES LESS THAN ( TO_DAYS('2007-03-08') ), -PARTITION p1 VALUES LESS THAN ( TO_DAYS('2007-04-01') ) -); -INSERT INTO t1 VALUES ('2007-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2007-03-07 12:00:00'); -INSERT INTO t1 VALUES ('2007-03-08 12:00:00'); -INSERT INTO t1 VALUES ('2007-03-15 12:00:00'); -explain format = 'brief' select * from t1 where recdate < '2007-03-08 00:00:00'; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.recdate, 2007-03-08 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -drop table t1; -CREATE TABLE t1 ( recdate DATETIME NOT NULL ) -PARTITION BY RANGE( YEAR(recdate) ) ( -PARTITION p0 VALUES LESS THAN (2006), -PARTITION p1 VALUES LESS THAN (2007) -); -INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); -explain format = 'brief' select * from t1 where recdate < '2006-01-01 00:00:00'; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t1.recdate, 2006-01-01 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -drop table t1; -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 (a int) -partition by range(a+0) ( -partition p0 values less than (64), -partition p1 values less than (128), -partition p2 values less than (255) -); -insert into t1 select A.a + 10*B.a from t0 A, t0 B; -explain format = 'brief' select * from t1 where a between 10 and 13; -id estRows task access object operator info -TableReader 250.00 root partition:p0 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 13) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -explain format = 'brief' select * from t1 where a between 10 and 10+33; -id estRows task access object operator info -TableReader 250.00 root partition:p0 data:Selection -└─Selection 250.00 cop[tikv] ge(test.t1.a, 10), le(test.t1.a, 43) - └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo -drop table t0, t1; -drop table if exists t; -create table t(a timestamp) partition by range(unix_timestamp(a)) (partition p0 values less than(unix_timestamp('2019-02-16 14:20:00')), partition p1 values less than (maxvalue)); -explain format = 'brief' select * from t where a between timestamp'2019-02-16 14:19:00' and timestamp'2019-02-16 14:21:00'; -id estRows task access object operator info -TableReader 250.00 root partition:all data:Selection -└─Selection 250.00 cop[tikv] ge(test.t.a, 2019-02-16 14:19:00), le(test.t.a, 2019-02-16 14:21:00) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -drop table if exists t; -create table t(a int) partition by range(a) (partition p0 values less than (100), partition p1 values less than (200), partition p2 values less than (300)); -begin; -explain format = 'brief' select * from t; -id estRows task access object operator info -TableReader 10000.00 root partition:all data:TableFullScan -└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -insert into t values(1); -explain format = 'brief' select * from t; -id estRows task access object operator info -Projection 10000.00 root test.t.a -└─UnionScan 10000.00 root - └─TableReader 10000.00 root partition:all data:TableFullScan - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -rollback; -begin; -insert into t values(101); -explain format = 'brief' select * from t; -id estRows task access object operator info -Projection 10000.00 root test.t.a -└─UnionScan 10000.00 root - └─TableReader 10000.00 root partition:all data:TableFullScan - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -rollback; -begin; -insert into t values(201); -explain format = 'brief' select * from t; -id estRows task access object operator info -Projection 10000.00 root test.t.a -└─UnionScan 10000.00 root - └─TableReader 10000.00 root partition:all data:TableFullScan - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -rollback; -explain format = 'brief' select * from t; -id estRows task access object operator info -TableReader 10000.00 root partition:all data:TableFullScan -└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -drop table if exists t; -CREATE TABLE `t` ( -`a` int(11) DEFAULT NULL, -`b` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin -PARTITION BY RANGE COLUMNS(a) ( -PARTITION p0 VALUES LESS THAN (1), -PARTITION p1 VALUES LESS THAN (10), -PARTITION p2 VALUES LESS THAN (100) -); -desc select * from t where a = 11 and b = 1 or a = 12 and b = 1; -id estRows task access object operator info -TableReader_7 0.02 root partition:p2 data:Selection_6 -└─Selection_6 0.02 cop[tikv] or(and(eq(test.t.a, 11), eq(test.t.b, 1)), and(eq(test.t.a, 12), eq(test.t.b, 1))) - └─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -drop table if exists t; -create table t (ts timestamp(3) not null default current_timestamp(3)) -partition by range (floor(unix_timestamp(ts))) ( -partition p0 values less than (unix_timestamp('2020-04-05 00:00:00')), -partition p1 values less than (unix_timestamp('2020-04-15 00:00:00')), -partition p2 values less than (unix_timestamp('2020-04-25 00:00:00')) -); -explain format = 'brief' select * from t where ts = '2020-04-06 00:00:00' -- p1; -id estRows task access object operator info -TableReader 10.00 root partition:p1 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t.ts, 2020-04-06 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts = '2020-04-05 00:00:00.001' -- p1; -id estRows task access object operator info -TableReader 10.00 root partition:p1 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t.ts, 2020-04-05 00:00:00.001000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts > '2020-04-15 00:00:00' -- p2; -id estRows task access object operator info -TableReader 3333.33 root partition:p2 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t.ts, 2020-04-15 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts > '2020-04-14 23:59:59.999' -- p1,p2; -id estRows task access object operator info -TableReader 3333.33 root partition:p1,p2 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t.ts, 2020-04-14 23:59:59.999000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts > '2020-04-15 00:00:00.001' -- p2; -id estRows task access object operator info -TableReader 3333.33 root partition:p2 data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t.ts, 2020-04-15 00:00:00.001000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts > '2020-04-26 00:00:00.001' -- dual; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] gt(test.t.ts, 2020-04-26 00:00:00.001000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts >= '2020-04-04 12:22:32' -- p0,p1,p2; -id estRows task access object operator info -TableReader 3333.33 root partition:all data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t.ts, 2020-04-04 12:22:32.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts >= '2020-04-05 00:00:00' -- p1,p2; -id estRows task access object operator info -TableReader 3333.33 root partition:p1,p2 data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t.ts, 2020-04-05 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts >= '2020-04-25 00:00:00' -- dual; -id estRows task access object operator info -TableReader 3333.33 root partition:dual data:Selection -└─Selection 3333.33 cop[tikv] ge(test.t.ts, 2020-04-25 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts < '2020-04-25 00:00:00' -- p0,p1,p2; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t.ts, 2020-04-25 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts < '2020-04-15 00:00:00.001' -- p0,p1,p2; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t.ts, 2020-04-15 00:00:00.001000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts < '2020-04-15 00:00:00' -- expect perfect : p0,p1, obtain: p0,p1,p2; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t.ts, 2020-04-15 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts < '2020-04-14 23:59:59.999' -- p0,p1; -id estRows task access object operator info -TableReader 3323.33 root partition:p0,p1 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t.ts, 2020-04-14 23:59:59.999000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts < '2020-04-03 00:00:00' -- p0; -id estRows task access object operator info -TableReader 3323.33 root partition:p0 data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t.ts, 2020-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts < '2021-05-03 00:00:00' -- p0,p1,p2; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] lt(test.t.ts, 2021-05-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts <= '2020-04-05 00:00:00' -- p0,p1; -id estRows task access object operator info -TableReader 3323.33 root partition:p0,p1 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t.ts, 2020-04-05 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts <= '2020-04-03 00:00:00' -- p0; -id estRows task access object operator info -TableReader 3323.33 root partition:p0 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t.ts, 2020-04-03 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts <= '2020-04-14 23:59:59.123' -- p0,p1; -id estRows task access object operator info -TableReader 3323.33 root partition:p0,p1 data:Selection -└─Selection 3323.33 cop[tikv] le(test.t.ts, 2020-04-14 23:59:59.123000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts <= '2020-04-25 00:00:00' -- p0,p1,p2; -id estRows task access object operator info -TableReader 3323.33 root partition:all data:Selection -└─Selection 3323.33 cop[tikv] le(test.t.ts, 2020-04-25 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts > '2020-04-25 00:00:00' or ts < '2020-01-02 00:00:00' -- p0; -id estRows task access object operator info -TableReader 6656.67 root partition:p0 data:Selection -└─Selection 6656.67 cop[tikv] or(gt(test.t.ts, 2020-04-25 00:00:00.000000), lt(test.t.ts, 2020-01-02 00:00:00.000000)) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -explain format = 'brief' select * from t where ts > '2020-04-02 00:00:00' and ts < '2020-04-07 00:00:00' -- p0,p1; -id estRows task access object operator info -TableReader 250.00 root partition:p0,p1 data:Selection -└─Selection 250.00 cop[tikv] gt(test.t.ts, 2020-04-02 00:00:00.000000), lt(test.t.ts, 2020-04-07 00:00:00.000000) - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo -drop table if exists t; -create table t (id int, name varchar(20)) partition by hash(id) partitions 128; -explain format = 'brief' SELECT * FROM t partition (p1) where name = '1'; -id estRows task access object operator info -TableReader 10.00 root partition:p1 data:Selection -└─Selection 10.00 cop[tikv] eq(test.t.name, "1") - └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo diff --git a/cmd/explaintest/t/partition_pruning.test b/cmd/explaintest/t/partition_pruning.test deleted file mode 100644 index cd322a0679c6c..0000000000000 --- a/cmd/explaintest/t/partition_pruning.test +++ /dev/null @@ -1,1017 +0,0 @@ -set @@session.tidb_enable_table_partition=1; -# -# Partition pruning tests. Currently we only detect which partitions to -# prune, so the test is EXPLAINs. -# --- source include/have_partition.inc - ---disable_warnings -drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; ---enable_warnings - ---echo # ---echo # Bug#53806: Wrong estimates for range query in partitioned MyISAM table ---echo # Bug#46754: 'rows' field doesn't reflect partition pruning ---echo # -CREATE TABLE t1 (a INT PRIMARY KEY) -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 max VALUES LESS THAN MAXVALUE); - -INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); - ---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 # -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; ---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 # -explain format = 'brief' SELECT * FROM t1 WHERE a < 7; ---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 # -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -DROP TABLE t1; - ---echo # ---echo # Bug#49742: Partition Pruning not working correctly for RANGE ---echo # -CREATE TABLE t1 (a INT PRIMARY KEY) -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 max VALUES LESS THAN MAXVALUE); - -INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); - -SELECT * FROM t1 WHERE a < 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 1; -SELECT * FROM t1 WHERE a < 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 2; -SELECT * FROM t1 WHERE a < 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 3; -SELECT * FROM t1 WHERE a < 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 4; -SELECT * FROM t1 WHERE a < 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 5; -SELECT * FROM t1 WHERE a < 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 6; -SELECT * FROM t1 WHERE a < 7 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 7; -SELECT * FROM t1 WHERE a <= 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -SELECT * FROM t1 WHERE a <= 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 2; -SELECT * FROM t1 WHERE a <= 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 3; -SELECT * FROM t1 WHERE a <= 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 4; -SELECT * FROM t1 WHERE a <= 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 5; -SELECT * FROM t1 WHERE a <= 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 6; -SELECT * FROM t1 WHERE a <= 7 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 7; -SELECT * FROM t1 WHERE a = 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 1; -SELECT * FROM t1 WHERE a = 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 2; -SELECT * FROM t1 WHERE a = 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 3; -SELECT * FROM t1 WHERE a = 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 4; -SELECT * FROM t1 WHERE a = 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 5; -SELECT * FROM t1 WHERE a = 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 6; -SELECT * FROM t1 WHERE a = 7 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a = 7; -SELECT * FROM t1 WHERE a >= 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 1; -SELECT * FROM t1 WHERE a >= 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 2; -SELECT * FROM t1 WHERE a >= 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 3; -SELECT * FROM t1 WHERE a >= 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 4; -SELECT * FROM t1 WHERE a >= 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 5; -SELECT * FROM t1 WHERE a >= 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 6; -SELECT * FROM t1 WHERE a >= 7 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 7; -SELECT * FROM t1 WHERE a > 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 1; -SELECT * FROM t1 WHERE a > 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 2; -SELECT * FROM t1 WHERE a > 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 3; -SELECT * FROM t1 WHERE a > 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 4; -SELECT * FROM t1 WHERE a > 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 5; -SELECT * FROM t1 WHERE a > 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 6; -SELECT * FROM t1 WHERE a > 7 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 7; -DROP TABLE t1; - -CREATE TABLE t1 (a INT PRIMARY KEY) -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 max VALUES LESS THAN MAXVALUE); - -INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7); - -SELECT * FROM t1 WHERE a < 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 1; -SELECT * FROM t1 WHERE a < 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 2; -SELECT * FROM t1 WHERE a < 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 3; -SELECT * FROM t1 WHERE a < 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 4; -SELECT * FROM t1 WHERE a < 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 5; -SELECT * FROM t1 WHERE a < 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a < 6; -SELECT * FROM t1 WHERE a <= 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 1; -SELECT * FROM t1 WHERE a <= 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 2; -SELECT * FROM t1 WHERE a <= 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 3; -SELECT * FROM t1 WHERE a <= 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 4; -SELECT * FROM t1 WHERE a <= 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 5; -SELECT * FROM t1 WHERE a <= 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a <= 6; -SELECT * FROM t1 WHERE a = 1; -explain format = 'brief' SELECT * FROM t1 WHERE a = 1; -SELECT * FROM t1 WHERE a = 2; -explain format = 'brief' SELECT * FROM t1 WHERE a = 2; -SELECT * FROM t1 WHERE a = 3; -explain format = 'brief' SELECT * FROM t1 WHERE a = 3; -SELECT * FROM t1 WHERE a = 4; -explain format = 'brief' SELECT * FROM t1 WHERE a = 4; -SELECT * FROM t1 WHERE a = 5; -explain format = 'brief' SELECT * FROM t1 WHERE a = 5; -SELECT * FROM t1 WHERE a = 6; -explain format = 'brief' SELECT * FROM t1 WHERE a = 6; -SELECT * FROM t1 WHERE a >= 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 1; -SELECT * FROM t1 WHERE a >= 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 2; -SELECT * FROM t1 WHERE a >= 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 3; -SELECT * FROM t1 WHERE a >= 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 4; -SELECT * FROM t1 WHERE a >= 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 5; -SELECT * FROM t1 WHERE a >= 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a >= 6; -SELECT * FROM t1 WHERE a > 1 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 1; -SELECT * FROM t1 WHERE a > 2 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 2; -SELECT * FROM t1 WHERE a > 3 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 3; -SELECT * FROM t1 WHERE a > 4 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 4; -SELECT * FROM t1 WHERE a > 5 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 5; -SELECT * FROM t1 WHERE a > 6 order by a; -explain format = 'brief' SELECT * FROM t1 WHERE a > 6; -DROP TABLE t1; - -# -# Bug#20577: Partitions: use of to_days() function leads to selection failures -# ---echo # test of RANGE and index -CREATE TABLE t1 (a DATE, KEY(a)) -PARTITION BY RANGE (TO_DAYS(a)) -(PARTITION `pNULL` VALUES LESS THAN (0), - PARTITION `p0001-01-01` VALUES LESS THAN (366 + 1), - PARTITION `p1001-01-01` VALUES LESS THAN (TO_DAYS('1001-01-01') + 1), - PARTITION `p2001-01-01` VALUES LESS THAN (TO_DAYS('2001-01-01') + 1)); -SET SQL_MODE = ''; -INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'), - ('1001-00-00'), ('1001-01-01'), ('1002-00-00'), ('2001-01-01'); ---source include/partition_date_range.inc ---echo # test without index -ALTER TABLE t1 DROP KEY a; ---source include/partition_date_range.inc -DROP TABLE t1; - - -# -# Bug#46362: Endpoint should be set to false for TO_DAYS(DATE) -# There is a problem when comparing DATE with DATETIME. -# In pruning it is converted into the field type -# and in row evaluation it is converted to longlong -# (like a DATETIME). ---echo # Test with DATETIME column NOT NULL -CREATE TABLE t1 ( - a int(10) unsigned NOT NULL, - b DATETIME NOT NULL, - PRIMARY KEY (a, b) -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), - PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), - PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), - PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), - PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), - (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-02 23:59:59'), - (1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), - (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -DROP TABLE t1; - ---echo # Test with DATE column NOT NULL -CREATE TABLE t1 ( - a int(10) unsigned NOT NULL, - b DATE NOT NULL, - PRIMARY KEY (a, b) -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), - PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), - PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), - PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), - PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), - (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-03'), (2, '2009-04-03'), - (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), - (1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -DROP TABLE t1; - ---echo # Test with DATETIME column NULL -CREATE TABLE t1 ( - a int(10) unsigned NOT NULL, - b DATETIME NULL -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), - PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), - PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), - PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), - PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), - (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-02 23:59:59'), - (1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), - (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -DROP TABLE t1; - ---echo # Test with DATE column NULL -CREATE TABLE t1 ( - a int(10) unsigned NOT NULL, - b DATE NULL -) PARTITION BY RANGE (TO_DAYS(b)) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), - PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), - PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), - PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), - PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), - (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-03'), (2, '2009-04-03'), - (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), - (1, '2009-04-07'); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; -explain format = 'brief' SELECT * FROM t1 WHERE b < '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b <= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b = '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b >= '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 WHERE b > '2009-04-03'; -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); -explain format = 'brief' SELECT * FROM t1 - WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); -DROP TABLE t1; - ---echo # For better code coverage of the patch -CREATE TABLE t1 ( - a int(10) unsigned NOT NULL, - b DATE -) PARTITION BY RANGE ( TO_DAYS(b) ) -(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), - PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), - PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), - PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), - PARTITION p20090405 VALUES LESS THAN MAXVALUE); -INSERT INTO t1 VALUES (1, '2009-01-01'), (2, NULL); ---echo # test with an invalid date, which lead to item->null_value is set. -explain format = 'brief' SELECT * FROM t1 WHERE b < CAST('2009-04-99' AS DATETIME); -DROP TABLE t1; - -# -# Bug#40972: some sql execution lead the whole database crashing -# -# Setup so the start is at partition pX and end is at p1 -# Pruning does handle 'bad' dates differently. -CREATE TABLE t1 -(a INT NOT NULL AUTO_INCREMENT, - b DATETIME, - PRIMARY KEY (a,b), - KEY (b)) -PARTITION BY RANGE (to_days(b)) -(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01', - PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01', - PARTITION pX VALUES LESS THAN MAXVALUE); -SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00'; -DROP TABLE t1; - -# RANGE(expr) partitioning -create table t3 ( - a int -) -partition by range (a*1) ( - partition p0 values less than (10), - partition p1 values less than (20) -); -insert into t3 values (5),(15); - -explain format = 'brief' select * from t3 where a=11; -explain format = 'brief' select * from t3 where a=10; -explain format = 'brief' select * from t3 where a=20; - -explain format = 'brief' select * from t3 where a=30; - -# RANGE(field) partitioning, interval analysis. -create table t7 (a int not null) partition by RANGE(a) ( - partition p10 values less than (10), - partition p30 values less than (30), - partition p50 values less than (50), - partition p70 values less than (70), - partition p90 values less than (90) -); -insert into t7 values (10),(30),(50); - -# leftmost intervals -explain format = 'brief' select * from t7 where a < 5; -explain format = 'brief' select * from t7 where a < 9; -explain format = 'brief' select * from t7 where a <= 9; -explain format = 'brief' select * from t7 where a = 9; -explain format = 'brief' select * from t7 where a >= 9; -explain format = 'brief' select * from t7 where a > 9; -explain format = 'brief' select * from t7 where a < 10; -explain format = 'brief' select * from t7 where a <= 10; -explain format = 'brief' select * from t7 where a = 10; -explain format = 'brief' select * from t7 where a >= 10; -explain format = 'brief' select * from t7 where a > 10; - -#rightmost intervals -explain format = 'brief' select * from t7 where a < 89; -explain format = 'brief' select * from t7 where a <= 89; -explain format = 'brief' select * from t7 where a = 89; -explain format = 'brief' select * from t7 where a > 89; -explain format = 'brief' select * from t7 where a >= 89; -explain format = 'brief' select * from t7 where a < 90; -explain format = 'brief' select * from t7 where a <= 90; -explain format = 'brief' select * from t7 where a = 90; -explain format = 'brief' select * from t7 where a > 90; -explain format = 'brief' select * from t7 where a >= 90; -explain format = 'brief' select * from t7 where a > 91; - -# misc intervals -explain format = 'brief' select * from t7 where a > 11 and a < 29; - -drop table t7; - -create table t7 (a int unsigned not null) partition by RANGE(a) ( - partition p10 values less than (10), - partition p30 values less than (30), - partition p50 values less than (50), - partition p70 values less than (70), - partition p90 values less than (90) -); -insert into t7 values (10),(30),(50); - -# leftmost intervals -explain format = 'brief' select * from t7 where a < 5; -explain format = 'brief' select * from t7 where a < 9; -explain format = 'brief' select * from t7 where a <= 9; -explain format = 'brief' select * from t7 where a = 9; -explain format = 'brief' select * from t7 where a >= 9; -explain format = 'brief' select * from t7 where a > 9; -explain format = 'brief' select * from t7 where a < 10; -explain format = 'brief' select * from t7 where a <= 10; -explain format = 'brief' select * from t7 where a = 10; -explain format = 'brief' select * from t7 where a >= 10; -explain format = 'brief' select * from t7 where a > 10; - -#rightmost intervals -explain format = 'brief' select * from t7 where a < 89; -explain format = 'brief' select * from t7 where a <= 89; -explain format = 'brief' select * from t7 where a = 89; -explain format = 'brief' select * from t7 where a > 89; -explain format = 'brief' select * from t7 where a >= 89; -explain format = 'brief' select * from t7 where a < 90; -explain format = 'brief' select * from t7 where a <= 90; -explain format = 'brief' select * from t7 where a = 90; -explain format = 'brief' select * from t7 where a > 90; -explain format = 'brief' select * from t7 where a >= 90; -explain format = 'brief' select * from t7 where a > 91; - -# misc intervals -explain format = 'brief' select * from t7 where a > 11 and a < 29; - -# LIST(monontonic_func) partitioning -create table t8 (a date not null) partition by RANGE(YEAR(a)) ( - partition p0 values less than (1980), - partition p1 values less than (1990), - partition p2 values less than (2000) -); -insert into t8 values ('1985-05-05'),('1995-05-05'); - -explain format = 'brief' select * from t8 where a < '1980-02-02'; - -# LIST(strict_monotonic_func) partitioning -create table t9 (a date not null) partition by RANGE(TO_DAYS(a)) ( - partition p0 values less than (732299), -- 2004-12-19 - partition p1 values less than (732468), -- 2005-06-06 - partition p2 values less than (732664) -- 2005-12-19 -); -insert into t9 values ('2005-05-05'), ('2005-04-04'); - -explain format = 'brief' select * from t9 where a < '2004-12-19'; -explain format = 'brief' select * from t9 where a <= '2004-12-19'; - -drop table t7,t8,t9; - -# -# Test cases for bugs found in code review: -# -create table t1 ( - a1 int not null -) -partition by range (a1) ( - partition p0 values less than (3), - partition p1 values less than (6), - partition p2 values less than (9) -); -insert into t1 values (1),(2),(3); -explain format = 'brief' select * from t1 where a1 > 3; -explain format = 'brief' select * from t1 where a1 >= 3; - -explain format = 'brief' select * from t1 where a1 < 3 and a1 > 3; -drop table t1; - -# Test partition pruning for single-table UPDATE/DELETE. -# TODO: Currently we test only "all partitions pruned away" case. Add more -# tests when the patch that makes use of partition pruning results at -# execution phase is pushed. - -# -# WL#2986 Tests (Checking if partition pruning results are used at query -# execution phase) -# -CREATE TABLE `t1` ( - `a` int(11) default NULL -); -INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -CREATE TABLE `t2` ( - `a` int(11) default NULL, - KEY `a` (`a`) -) ; - -insert into t2 select A.a + 10*(B.a + 10* C.a) from t1 A, t1 B, t1 C ; -insert into t1 select a from t2; - -drop table t2; -CREATE TABLE `t2` ( - `a` int(11) default NULL, - `b` int(11) default NULL -) -PARTITION BY RANGE (a) ( -PARTITION p0 VALUES LESS THAN (200), -PARTITION p1 VALUES LESS THAN (400), -PARTITION p2 VALUES LESS THAN (600), -PARTITION p3 VALUES LESS THAN (800), -PARTITION p4 VALUES LESS THAN (1001)); - -insert into t2 select a,1 from t1 where a < 200; -insert into t2 select a,2 from t1 where a >= 200 and a < 400; -insert into t2 select a,3 from t1 where a >= 400 and a < 600; -insert into t2 select a,4 from t1 where a >= 600 and a < 800; -insert into t2 select a,5 from t1 where a >= 800 and a < 1001; - -explain format = 'brief' select * from t2; -explain format = 'brief' select * from t2 where a < 801 and a > 200; -explain format = 'brief' select * from t2 where a < 801 and a > 800; -explain format = 'brief' select * from t2 where a > 600; -explain format = 'brief' select * from t2 where a > 600 and b = 1; -explain format = 'brief' select * from t2 where a > 600 and b = 4; -explain format = 'brief' select * from t2 where a > 600 and b = 5; -explain format = 'brief' select * from t2 where b = 5; - -flush status; -update t2 set b = 100 where b = 6; -show status like 'Handler_read_rnd_next'; -flush status; -update t2 set a = 1002 where a = 1001; -show status like 'Handler_read_rnd_next'; -flush status; -update t2 set b = 6 where a = 600; -show status like 'Handler_read_rnd_next'; -flush status; -update t2 set b = 6 where a > 600 and a < 800; -show status like 'Handler_read_rnd_next'; -flush status; -delete from t2 where a > 600; -show status like 'Handler_read_rnd_next'; - -drop table t2; -CREATE TABLE `t2` ( - `a` int(11) default NULL, - `b` int(11) default NULL, - index (b) -) -PARTITION BY RANGE (a) ( -PARTITION p0 VALUES LESS THAN (200), -PARTITION p1 VALUES LESS THAN (400), -PARTITION p2 VALUES LESS THAN (600), -PARTITION p3 VALUES LESS THAN (800), -PARTITION p4 VALUES LESS THAN (1001)); - -insert into t2 select a,1 from t1 where a < 100; -insert into t2 select a,2 from t1 where a >= 200 and a < 300; -insert into t2 select a,3 from t1 where a >= 300 and a < 400; -insert into t2 select a,4 from t1 where a >= 400 and a < 500; -insert into t2 select a,5 from t1 where a >= 500 and a < 600; -insert into t2 select a,6 from t1 where a >= 600 and a < 700; -insert into t2 select a,7 from t1 where a >= 700 and a < 800; -insert into t2 select a,8 from t1 where a >= 800 and a < 900; -insert into t2 select a,9 from t1 where a >= 900 and a < 1001; - -explain format = 'brief' select * from t2; -# not using indexes -explain format = 'brief' select * from t2 where a = 101; -explain format = 'brief' select * from t2 where a = 550; -explain format = 'brief' select * from t2 where a = 833; -explain format = 'brief' select * from t2 where a in (10,20,30); -explain format = 'brief' select * from t2 where (a = 100 OR a = 900); -explain format = 'brief' select * from t2 where (a > 100 AND a < 600); -explain format = 'brief' select * from t2 where b = 4; - -explain format = 'brief' select * from t2 where b = 6; - -explain format = 'brief' select * from t2 where b in (1,3,5); - -explain format = 'brief' select * from t2 where b in (2,4,6); - -explain format = 'brief' select * from t2 where b in (7,8,9); - -explain format = 'brief' select * from t2 where b > 5; - -explain format = 'brief' select * from t2 where b > 5 and b < 8; - -explain format = 'brief' select * from t2 where b > 5 and b < 7; - -explain format = 'brief' select * from t2 where b > 0 and b < 5; - -flush status; -update t2 set a = 111 where b = 10; -show status like 'Handler_read_rnd_next'; -show status like 'Handler_read_key'; -flush status; -update t2 set a = 111 where b in (5,6); -show status like 'Handler_read_rnd_next'; -show status like 'Handler_read_key'; -flush status; -update t2 set a = 222 where b = 7; -show status like 'Handler_read_rnd_next'; -show status like 'Handler_read_key'; -flush status; -delete from t2 where b = 7; -show status like 'Handler_read_rnd_next'; -show status like 'Handler_read_key'; -flush status; -delete from t2 where b > 5; -show status like 'Handler_read_rnd_next'; -show status like 'Handler_read_key'; -show status like 'Handler_read_prev'; -show status like 'Handler_read_next'; -flush status; -delete from t2 where b < 5 or b > 3; -show status like 'Handler_read_rnd_next'; -show status like 'Handler_read_key'; -show status like 'Handler_read_prev'; -show status like 'Handler_read_next'; - -drop table t1, t2; - -# BUG#20484 "Partitions: crash with explain format = 'brief' and union" -create table t1 (s1 int); -explain format = 'brief' select 1 from t1 union all select 2; -drop table t1; - -# -# Test all variants of usage for interval_via_mapping -# and interval_via_walking -# -# t1 will use interval_via_mapping since it uses a -# monotonic function, whereas t2 will use -# interval_via_walking since the intervals are short -# and the function isn't monotonic (it is, but it isn't -# discovered in this version). -# - create table t1 (a int) - partition by range(a) ( - partition p0 values less than (64), - partition p1 values less than (128), - partition p2 values less than (255) -); - -create table t2 (a int) - partition by range(a+0) ( - partition p0 values less than (64), - partition p1 values less than (128), - partition p2 values less than (255) -); - -insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); -insert into t2 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); -explain format = 'brief' select * from t1 where a=0; -explain format = 'brief' select * from t2 where a=0; -explain format = 'brief' select * from t1 where a=0xFE; -explain format = 'brief' select * from t2 where a=0xFE; -explain format = 'brief' select * from t1 where a > 0xFE AND a <= 0xFF; -explain format = 'brief' select * from t2 where a > 0xFE AND a <= 0xFF; -explain format = 'brief' select * from t1 where a >= 0xFE AND a <= 0xFF; -explain format = 'brief' select * from t2 where a >= 0xFE AND a <= 0xFF; -explain format = 'brief' select * from t1 where a < 64 AND a >= 63; -explain format = 'brief' select * from t2 where a < 64 AND a >= 63; -explain format = 'brief' select * from t1 where a <= 64 AND a >= 63; -explain format = 'brief' select * from t2 where a <= 64 AND a >= 63; -drop table t1; -drop table t2; - -create table t1(a bigint unsigned not null) partition by range(a+0) ( - partition p1 values less than (10), - partition p2 values less than (20), - partition p3 values less than (2305561538531885056), - partition p4 values less than (2305561538531950591) -); - -insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); -insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); - -explain format = 'brief' select * from t1 where - a >= 2305561538531885056-10 and a <= 2305561538531885056-8; - -explain format = 'brief' select * from t1 where - a > 0xFFFFFFFFFFFFFFEC and a < 0xFFFFFFFFFFFFFFEE; - -explain format = 'brief' select * from t1 where a>=0 and a <= 0xFFFFFFFFFFFFFFFF; -drop table t1; - -create table t1 (a bigint) partition by range(a+0) ( - partition p1 values less than (-1000), - partition p2 values less than (-10), - partition p3 values less than (10), - partition p4 values less than (1000) -); -insert into t1 values (-15),(-5),(5),(15),(-15),(-5),(5),(15); -explain format = 'brief' select * from t1 where a>-2 and a <=0; -drop table t1; - - -# -# BUG#27927 Partition pruning not optimal with TO_DAYS function -# - -CREATE TABLE t1 ( recdate DATETIME NOT NULL ) -PARTITION BY RANGE( TO_DAYS(recdate) ) ( - PARTITION p0 VALUES LESS THAN ( TO_DAYS('2007-03-08') ), - PARTITION p1 VALUES LESS THAN ( TO_DAYS('2007-04-01') ) -); -INSERT INTO t1 VALUES ('2007-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2007-03-07 12:00:00'); -INSERT INTO t1 VALUES ('2007-03-08 12:00:00'); -INSERT INTO t1 VALUES ('2007-03-15 12:00:00'); --- echo must use p0 only: -explain format = 'brief' select * from t1 where recdate < '2007-03-08 00:00:00'; - -drop table t1; -CREATE TABLE t1 ( recdate DATETIME NOT NULL ) -PARTITION BY RANGE( YEAR(recdate) ) ( - PARTITION p0 VALUES LESS THAN (2006), - PARTITION p1 VALUES LESS THAN (2007) -); -INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); -INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); - --- echo must use p0 only: -explain format = 'brief' select * from t1 where recdate < '2006-01-01 00:00:00'; -drop table t1; - --- echo # --- echo # BUG#33730 Full table scan instead selected partitions for query more than 10 partitions --- echo # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 (a int) - partition by range(a+0) ( - partition p0 values less than (64), - partition p1 values less than (128), - partition p2 values less than (255) -); -insert into t1 select A.a + 10*B.a from t0 A, t0 B; - -# this will use interval_via_walking -explain format = 'brief' select * from t1 where a between 10 and 13; -explain format = 'brief' select * from t1 where a between 10 and 10+33; - -drop table t0, t1; - -drop table if exists t; -create table t(a timestamp) partition by range(unix_timestamp(a)) (partition p0 values less than(unix_timestamp('2019-02-16 14:20:00')), partition p1 values less than (maxvalue)); -explain format = 'brief' select * from t where a between timestamp'2019-02-16 14:19:00' and timestamp'2019-02-16 14:21:00'; - -drop table if exists t; -create table t(a int) partition by range(a) (partition p0 values less than (100), partition p1 values less than (200), partition p2 values less than (300)); -begin; -explain format = 'brief' select * from t; -insert into t values(1); -explain format = 'brief' select * from t; -rollback; -begin; -insert into t values(101); -explain format = 'brief' select * from t; -rollback; -begin; -insert into t values(201); -explain format = 'brief' select * from t; -rollback; -explain format = 'brief' select * from t; - -drop table if exists t; -CREATE TABLE `t` ( - `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin -PARTITION BY RANGE COLUMNS(a) ( - PARTITION p0 VALUES LESS THAN (1), - PARTITION p1 VALUES LESS THAN (10), - PARTITION p2 VALUES LESS THAN (100) -); - -desc select * from t where a = 11 and b = 1 or a = 12 and b = 1; - -# -# MySQL doesn't support partition pruning for 'floor(unix_timestamp(ts))' but it works on TiDB -# https://github.com/pingcap/tidb/issues/16354 -# -drop table if exists t; -create table t (ts timestamp(3) not null default current_timestamp(3)) -partition by range (floor(unix_timestamp(ts))) ( - partition p0 values less than (unix_timestamp('2020-04-05 00:00:00')), - partition p1 values less than (unix_timestamp('2020-04-15 00:00:00')), - partition p2 values less than (unix_timestamp('2020-04-25 00:00:00')) -); - -explain format = 'brief' select * from t where ts = '2020-04-06 00:00:00' -- p1; -explain format = 'brief' select * from t where ts = '2020-04-05 00:00:00.001' -- p1; -explain format = 'brief' select * from t where ts > '2020-04-15 00:00:00' -- p2; -explain format = 'brief' select * from t where ts > '2020-04-14 23:59:59.999' -- p1,p2; -explain format = 'brief' select * from t where ts > '2020-04-15 00:00:00.001' -- p2; -explain format = 'brief' select * from t where ts > '2020-04-26 00:00:00.001' -- dual; -explain format = 'brief' select * from t where ts >= '2020-04-04 12:22:32' -- p0,p1,p2; -explain format = 'brief' select * from t where ts >= '2020-04-05 00:00:00' -- p1,p2; -explain format = 'brief' select * from t where ts >= '2020-04-25 00:00:00' -- dual; -explain format = 'brief' select * from t where ts < '2020-04-25 00:00:00' -- p0,p1,p2; -explain format = 'brief' select * from t where ts < '2020-04-15 00:00:00.001' -- p0,p1,p2; -explain format = 'brief' select * from t where ts < '2020-04-15 00:00:00' -- expect perfect : p0,p1, obtain: p0,p1,p2; -explain format = 'brief' select * from t where ts < '2020-04-14 23:59:59.999' -- p0,p1; -explain format = 'brief' select * from t where ts < '2020-04-03 00:00:00' -- p0; -explain format = 'brief' select * from t where ts < '2021-05-03 00:00:00' -- p0,p1,p2; -explain format = 'brief' select * from t where ts <= '2020-04-05 00:00:00' -- p0,p1; -explain format = 'brief' select * from t where ts <= '2020-04-03 00:00:00' -- p0; -explain format = 'brief' select * from t where ts <= '2020-04-14 23:59:59.123' -- p0,p1; -explain format = 'brief' select * from t where ts <= '2020-04-25 00:00:00' -- p0,p1,p2; -explain format = 'brief' select * from t where ts > '2020-04-25 00:00:00' or ts < '2020-01-02 00:00:00' -- p0; -explain format = 'brief' select * from t where ts > '2020-04-02 00:00:00' and ts < '2020-04-07 00:00:00' -- p0,p1; - -drop table if exists t; -create table t (id int, name varchar(20)) partition by hash(id) partitions 128; -explain format = 'brief' SELECT * FROM t partition (p1) where name = '1';