diff --git a/cmd/explaintest/r/access_path_selection.result b/cmd/explaintest/r/access_path_selection.result index 3e857d0b1d028..d178e09f8e03c 100644 --- a/cmd/explaintest/r/access_path_selection.result +++ b/cmd/explaintest/r/access_path_selection.result @@ -15,9 +15,9 @@ IndexReader_6 3323.33 root index:IndexScan_5 └─IndexScan_5 3323.33 cop table:access_path_selection, index:a, b, range:[-inf,3), keep order:false, stats:pseudo explain select a, b from access_path_selection where b < 3; id count task operator info -IndexLookUp_10 3323.33 root -├─IndexScan_8 3323.33 cop table:access_path_selection, index:b, range:[-inf,3), keep order:false, stats:pseudo -└─TableScan_9 3323.33 cop table:access_path_selection, keep order:false, stats:pseudo +IndexLookUp_7 3323.33 root +├─IndexScan_5 3323.33 cop table:access_path_selection, index:b, range:[-inf,3), keep order:false, stats:pseudo +└─TableScan_6 3323.33 cop table:access_path_selection, keep order:false, stats:pseudo explain select a, b from access_path_selection where a < 3 and b < 3; id count task operator info IndexReader_11 1104.45 root index:Selection_10 diff --git a/cmd/explaintest/r/explain_easy.result b/cmd/explaintest/r/explain_easy.result index a5bc3fd362849..2c9ed5f634306 100644 --- a/cmd/explaintest/r/explain_easy.result +++ b/cmd/explaintest/r/explain_easy.result @@ -90,11 +90,11 @@ explain select sum(t1.c1 in (select c1 from t2)) from t1; id count task operator info StreamAgg_12 1.00 root funcs:sum(col_0) └─Projection_19 10000.00 root cast(5_aux_0) - └─HashLeftJoin_18 10000.00 root CARTESIAN left outer semi join, inner:TableReader_17, other cond:eq(test.t1.c1, test.t2.c1) - ├─TableReader_15 10000.00 root data:TableScan_14 - │ └─TableScan_14 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo - └─TableReader_17 10000.00 root data:TableScan_16 - └─TableScan_16 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo + └─HashLeftJoin_18 10000.00 root CARTESIAN left outer semi join, inner:IndexReader_17, other cond:eq(test.t1.c1, test.t2.c1) + ├─IndexReader_15 10000.00 root index:IndexScan_14 + │ └─IndexScan_14 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo + └─IndexReader_17 10000.00 root index:IndexScan_16 + └─IndexScan_16 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:false, stats:pseudo explain select c1 from t1 where c1 in (select c2 from t2); id count task operator info Projection_9 9990.00 root test.t1.c1 @@ -123,8 +123,8 @@ explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) id count task operator info Projection_12 10000.00 root eq(test.t1.c2, test.t2.c2) └─Apply_14 10000.00 root CARTESIAN left outer join, inner:Limit_21 - ├─TableReader_16 10000.00 root data:TableScan_15 - │ └─TableScan_15 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + ├─IndexReader_16 10000.00 root index:IndexScan_15 + │ └─IndexScan_15 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo └─Limit_21 1.00 root offset:0, count:1 └─Projection_41 1.00 root test.t2.c1, test.t2.c2 └─IndexLookUp_40 1.00 root @@ -155,12 +155,12 @@ Limit_8 1.00 root offset:0, count:1 └─TableScan_11 3.00 cop table:t4, range:(1,+inf], keep order:false, stats:pseudo explain select ifnull(null, t1.c1) from t1; id count task operator info -TableReader_5 10000.00 root data:TableScan_4 -└─TableScan_4 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo +IndexReader_5 10000.00 root index:IndexScan_4 +└─IndexScan_4 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo explain select if(10, t1.c1, t1.c2) from t1; id count task operator info -TableReader_5 10000.00 root data:TableScan_4 -└─TableScan_4 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo +IndexReader_5 10000.00 root index:IndexScan_4 +└─IndexScan_4 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo explain select c1 from t2 union select c1 from t2 union all select c1 from t2; id count task operator info Union_17 26000.00 root @@ -174,8 +174,8 @@ Union_17 26000.00 root │ └─IndexReader_50 8000.00 root index:StreamAgg_41 │ └─StreamAgg_41 8000.00 cop group by:test.t2.c1, funcs:firstrow(test.t2.c1), firstrow(test.t2.c1) │ └─IndexScan_48 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:true, stats:pseudo -└─TableReader_55 10000.00 root data:TableScan_54 - └─TableScan_54 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo +└─IndexReader_55 10000.00 root index:IndexScan_54 + └─IndexScan_54 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:false, stats:pseudo explain select c1 from t2 union all select c1 from t2 union select c1 from t2; id count task operator info HashAgg_18 24000.00 root group by:c1, funcs:firstrow(join_agg_0) @@ -204,16 +204,16 @@ explain select 1 from (select count(c2), count(c3) from t1) k; id count task operator info Projection_5 1.00 root 1 └─StreamAgg_17 1.00 root funcs:firstrow(col_0) - └─TableReader_18 1.00 root data:StreamAgg_9 + └─IndexReader_18 1.00 root index:StreamAgg_9 └─StreamAgg_9 1.00 cop funcs:firstrow(1) - └─TableScan_16 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo explain select count(1) from (select max(c2), count(c3) as m from t1) k; id count task operator info StreamAgg_11 1.00 root funcs:count(1) └─StreamAgg_23 1.00 root funcs:firstrow(col_0) - └─TableReader_24 1.00 root data:StreamAgg_15 + └─IndexReader_24 1.00 root index:StreamAgg_15 └─StreamAgg_15 1.00 cop funcs:firstrow(1) - └─TableScan_22 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_22 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo explain select count(1) from (select count(c2) from t1 group by c3) k; id count task operator info StreamAgg_11 1.00 root funcs:count(1) @@ -226,17 +226,17 @@ explain select sum(t1.c1 in (select c1 from t2)) from t1; id count task operator info StreamAgg_12 1.00 root funcs:sum(col_0) └─Projection_19 10000.00 root cast(5_aux_0) - └─HashLeftJoin_18 10000.00 root CARTESIAN left outer semi join, inner:TableReader_17, other cond:eq(test.t1.c1, test.t2.c1) - ├─TableReader_15 10000.00 root data:TableScan_14 - │ └─TableScan_14 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo - └─TableReader_17 10000.00 root data:TableScan_16 - └─TableScan_16 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo + └─HashLeftJoin_18 10000.00 root CARTESIAN left outer semi join, inner:IndexReader_17, other cond:eq(test.t1.c1, test.t2.c1) + ├─IndexReader_15 10000.00 root index:IndexScan_14 + │ └─IndexScan_14 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo + └─IndexReader_17 10000.00 root index:IndexScan_16 + └─IndexScan_16 10000.00 cop table:t2, index:c1, range:[NULL,+inf], keep order:false, stats:pseudo explain select 1 in (select c2 from t2) from t1; id count task operator info Projection_6 10000.00 root 5_aux_0 └─HashLeftJoin_7 10000.00 root CARTESIAN left outer semi join, inner:TableReader_12 - ├─TableReader_9 10000.00 root data:TableScan_8 - │ └─TableScan_8 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + ├─IndexReader_9 10000.00 root index:IndexScan_8 + │ └─IndexScan_8 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo └─TableReader_12 10.00 root data:Selection_11 └─Selection_11 10.00 cop eq(1, test.t2.c2) └─TableScan_10 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo @@ -245,8 +245,8 @@ id count task operator info StreamAgg_12 1.00 root funcs:sum(col_0) └─Projection_20 10000.00 root cast(5_aux_0) └─HashLeftJoin_19 10000.00 root CARTESIAN left outer semi join, inner:TableReader_18 - ├─TableReader_15 10000.00 root data:TableScan_14 - │ └─TableScan_14 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + ├─IndexReader_15 10000.00 root index:IndexScan_14 + │ └─IndexScan_14 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo └─TableReader_18 10.00 root data:Selection_17 └─Selection_17 10.00 cop eq(6, test.t2.c2) └─TableScan_16 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo @@ -260,23 +260,23 @@ color=black label = "root" "StreamAgg_12" -> "Projection_19" "Projection_19" -> "HashLeftJoin_18" -"HashLeftJoin_18" -> "TableReader_15" -"HashLeftJoin_18" -> "TableReader_17" +"HashLeftJoin_18" -> "IndexReader_15" +"HashLeftJoin_18" -> "IndexReader_17" } subgraph cluster14{ node [style=filled, color=lightgrey] color=black label = "cop" -"TableScan_14" +"IndexScan_14" } subgraph cluster16{ node [style=filled, color=lightgrey] color=black label = "cop" -"TableScan_16" +"IndexScan_16" } -"TableReader_15" -> "TableScan_14" -"TableReader_17" -> "TableScan_16" +"IndexReader_15" -> "IndexScan_14" +"IndexReader_17" -> "IndexScan_16" } explain format="dot" select 1 in (select c2 from t2) from t1; @@ -288,14 +288,14 @@ node [style=filled, color=lightgrey] color=black label = "root" "Projection_6" -> "HashLeftJoin_7" -"HashLeftJoin_7" -> "TableReader_9" +"HashLeftJoin_7" -> "IndexReader_9" "HashLeftJoin_7" -> "TableReader_12" } subgraph cluster8{ node [style=filled, color=lightgrey] color=black label = "cop" -"TableScan_8" +"IndexScan_8" } subgraph cluster11{ node [style=filled, color=lightgrey] @@ -303,7 +303,7 @@ color=black label = "cop" "Selection_11" -> "TableScan_10" } -"TableReader_9" -> "TableScan_8" +"IndexReader_9" -> "IndexScan_8" "TableReader_12" -> "Selection_11" } @@ -423,9 +423,9 @@ IndexReader_6 10.00 root index:IndexScan_5 └─IndexScan_5 10.00 cop table:t, index:a, b, range:[1,1], keep order:false, stats:pseudo explain select * from t where b in (1, 2) and b in (1, 3); id count task operator info -TableReader_7 10.00 root data:Selection_6 -└─Selection_6 10.00 cop in(test.t.b, 1, 2), in(test.t.b, 1, 3) - └─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo +IndexReader_7 10.00 root index:Selection_6 +└─Selection_6 10.00 cop eq(test.t.b, 1) + └─IndexScan_5 10000.00 cop table:t, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo explain select * from t where a = 1 and a = 1; id count task operator info IndexReader_6 10.00 root index:IndexScan_5 @@ -439,20 +439,20 @@ TableDual_5 0.00 root rows:0 explain select * from t t1 join t t2 where t1.b = t2.b and t2.b is null; id count task operator info Projection_7 0.00 root test.t1.a, test.t1.b, test.t2.a, test.t2.b -└─HashRightJoin_9 0.00 root inner join, inner:TableReader_12, equal:[eq(test.t2.b, test.t1.b)] - ├─TableReader_12 0.00 root data:Selection_11 +└─HashRightJoin_9 0.00 root inner join, inner:IndexReader_12, equal:[eq(test.t2.b, test.t1.b)] + ├─IndexReader_12 0.00 root index:Selection_11 │ └─Selection_11 0.00 cop isnull(test.t2.b), not(isnull(test.t2.b)) - │ └─TableScan_10 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo - └─TableReader_15 9990.00 root data:Selection_14 + │ └─IndexScan_10 10000.00 cop table:t2, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo + └─IndexReader_15 9990.00 root index:Selection_14 └─Selection_14 9990.00 cop not(isnull(test.t1.b)) - └─TableScan_13 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_13 10000.00 cop table:t1, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo explain select * from t t1 where not exists (select * from t t2 where t1.b = t2.b); id count task operator info -HashLeftJoin_9 8000.00 root anti semi join, inner:TableReader_13, equal:[eq(test.t1.b, test.t2.b)] -├─TableReader_11 10000.00 root data:TableScan_10 -│ └─TableScan_10 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_13 10000.00 root data:TableScan_12 - └─TableScan_12 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo +HashLeftJoin_9 8000.00 root anti semi join, inner:IndexReader_13, equal:[eq(test.t1.b, test.t2.b)] +├─IndexReader_11 10000.00 root index:IndexScan_10 +│ └─IndexScan_10 10000.00 cop table:t1, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_13 10000.00 root index:IndexScan_12 + └─IndexScan_12 10000.00 cop table:t2, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo drop table if exists t; create table t(a bigint primary key); explain select * from t where a = 1 and a = 2; @@ -484,12 +484,12 @@ create table t1(a int, b int, c int, primary key(a, b)); create table t2(a int, b int, c int, primary key(a)); explain select t1.a, t1.b from t1 left outer join t2 on t1.a = t2.a; id count task operator info -TableReader_7 10000.00 root data:TableScan_6 -└─TableScan_6 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo +IndexReader_7 10000.00 root index:IndexScan_6 +└─IndexScan_6 10000.00 cop table:t1, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo explain select distinct t1.a, t1.b from t1 left outer join t2 on t1.a = t2.a; id count task operator info -TableReader_9 10000.00 root data:TableScan_8 -└─TableScan_8 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo +IndexReader_9 10000.00 root index:IndexScan_8 +└─IndexScan_8 10000.00 cop table:t1, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo drop table if exists t; create table t(a int, nb int not null, nc int not null); explain select ifnull(a, 0) from t; diff --git a/cmd/explaintest/r/explain_easy_stats.result b/cmd/explaintest/r/explain_easy_stats.result index 94b9b43381c29..9c82b0923467a 100644 --- a/cmd/explaintest/r/explain_easy_stats.result +++ b/cmd/explaintest/r/explain_easy_stats.result @@ -109,8 +109,8 @@ explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) id count task operator info Projection_12 1999.00 root eq(test.t1.c2, test.t2.c2) └─Apply_14 1999.00 root CARTESIAN left outer join, inner:Limit_21 - ├─TableReader_16 1999.00 root data:TableScan_15 - │ └─TableScan_15 1999.00 cop table:t1, range:[-inf,+inf], keep order:false + ├─IndexReader_16 1999.00 root index:IndexScan_15 + │ └─IndexScan_15 1999.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false └─Limit_21 1.00 root offset:0, count:1 └─Projection_41 1.00 root test.t2.c1, test.t2.c2 └─IndexLookUp_40 1.00 root @@ -128,8 +128,8 @@ explain select 1 in (select c2 from t2) from t1; id count task operator info Projection_6 1999.00 root 5_aux_0 └─HashLeftJoin_7 1999.00 root CARTESIAN left outer semi join, inner:TableReader_12 - ├─TableReader_9 1999.00 root data:TableScan_8 - │ └─TableScan_8 1999.00 cop table:t1, range:[-inf,+inf], keep order:false + ├─IndexReader_9 1999.00 root index:IndexScan_8 + │ └─IndexScan_8 1999.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false └─TableReader_12 0.00 root data:Selection_11 └─Selection_11 0.00 cop eq(1, test.t2.c2) └─TableScan_10 1985.00 cop table:t2, range:[-inf,+inf], keep order:false @@ -142,14 +142,14 @@ node [style=filled, color=lightgrey] color=black label = "root" "Projection_6" -> "HashLeftJoin_7" -"HashLeftJoin_7" -> "TableReader_9" +"HashLeftJoin_7" -> "IndexReader_9" "HashLeftJoin_7" -> "TableReader_12" } subgraph cluster8{ node [style=filled, color=lightgrey] color=black label = "cop" -"TableScan_8" +"IndexScan_8" } subgraph cluster11{ node [style=filled, color=lightgrey] @@ -157,7 +157,7 @@ color=black label = "cop" "Selection_11" -> "TableScan_10" } -"TableReader_9" -> "TableScan_8" +"IndexReader_9" -> "IndexScan_8" "TableReader_12" -> "Selection_11" } diff --git a/cmd/explaintest/r/generated_columns.result b/cmd/explaintest/r/generated_columns.result index 0add5d3921876..b8089dfb3a4f1 100644 --- a/cmd/explaintest/r/generated_columns.result +++ b/cmd/explaintest/r/generated_columns.result @@ -32,9 +32,9 @@ IndexReader_6 3323.33 root index:IndexScan_5 └─IndexScan_5 3323.33 cop table:sgc, index:a, b, range:[-inf,3), keep order:false, stats:pseudo EXPLAIN SELECT a, b from sgc where b < 3; id count task operator info -IndexLookUp_10 3323.33 root -├─IndexScan_8 3323.33 cop table:sgc, index:b, range:[-inf,3), keep order:false, stats:pseudo -└─TableScan_9 3323.33 cop table:sgc, keep order:false, stats:pseudo +IndexLookUp_7 3323.33 root +├─IndexScan_5 3323.33 cop table:sgc, index:b, range:[-inf,3), keep order:false, stats:pseudo +└─TableScan_6 3323.33 cop table:sgc, keep order:false, stats:pseudo EXPLAIN SELECT a, b from sgc where a < 3 and b < 3; id count task operator info IndexReader_11 1104.45 root index:Selection_10 diff --git a/cmd/explaintest/r/partition_pruning.result b/cmd/explaintest/r/partition_pruning.result index d4430618a0342..247f7037ded6c 100644 --- a/cmd/explaintest/r/partition_pruning.result +++ b/cmd/explaintest/r/partition_pruning.result @@ -1040,490 +1040,490 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_6 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_6 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03'; id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop le(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop le(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_6 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo DROP TABLE t1; # Test with DATE column NOT NULL CREATE TABLE t1 ( @@ -1543,490 +1543,490 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info -TableReader_8 0.00 root data:Selection_7 +IndexReader_8 0.00 root index:Selection_7 └─Selection_7 0.00 cop eq(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_6 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop le(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; id count task operator info -TableReader_8 0.00 root data:Selection_7 +IndexReader_8 0.00 root index:Selection_7 └─Selection_7 0.00 cop eq(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_6 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:59.000000) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < '2009-04-03'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= '2009-04-03'; id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = '2009-04-03'; id count task operator info -TableReader_8 10.00 root data:Selection_7 +IndexReader_8 10.00 root index:Selection_7 └─Selection_7 10.00 cop eq(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= '2009-04-03'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > '2009-04-03'; id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:00.000000) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop lt(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_9 9970.00 root -├─TableReader_12 3323.33 root data:Selection_11 +├─IndexReader_12 3323.33 root index:Selection_11 │ └─Selection_11 3323.33 cop le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_10 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_15 3323.33 root data:Selection_14 +│ └─IndexScan_10 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_15 3323.33 root index:Selection_14 │ └─Selection_14 3323.33 cop le(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_13 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_18 3323.33 root data:Selection_17 +│ └─IndexScan_13 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_18 3323.33 root index:Selection_17 └─Selection_17 3323.33 cop le(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_16 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_16 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info -TableReader_8 0.00 root data:Selection_7 +IndexReader_8 0.00 root index:Selection_7 └─Selection_7 0.00 cop eq(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_6 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop ge(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); id count task operator info Union_10 13333.33 root -├─TableReader_13 3333.33 root data:Selection_12 +├─IndexReader_13 3333.33 root index:Selection_12 │ └─Selection_12 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_11 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_16 3333.33 root data:Selection_15 +│ └─IndexScan_11 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_16 3333.33 root index:Selection_15 │ └─Selection_15 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_14 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_19 3333.33 root data:Selection_18 +│ └─IndexScan_14 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_19 3333.33 root index:Selection_18 │ └─Selection_18 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) -│ └─TableScan_17 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_22 3333.33 root data:Selection_21 +│ └─IndexScan_17 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_22 3333.33 root index:Selection_21 └─Selection_21 3333.33 cop gt(test.t1.b, 2009-04-03 00:00:01) - └─TableScan_20 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_20 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop lt(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_8 6646.67 root -├─TableReader_11 3323.33 root data:Selection_10 +├─IndexReader_11 3323.33 root index:Selection_10 │ └─Selection_10 3323.33 cop le(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_9 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_14 3323.33 root data:Selection_13 +│ └─IndexScan_9 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_14 3323.33 root index:Selection_13 └─Selection_13 3323.33 cop le(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_12 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_12 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info -TableReader_8 0.00 root data:Selection_7 +IndexReader_8 0.00 root index:Selection_7 └─Selection_7 0.00 cop eq(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_6 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_6 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop ge(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo EXPLAIN SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); id count task operator info Union_11 16666.67 root -├─TableReader_14 3333.33 root data:Selection_13 +├─IndexReader_14 3333.33 root index:Selection_13 │ └─Selection_13 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_12 10000.00 cop table:t1, partition:p20090401, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_17 3333.33 root data:Selection_16 +│ └─IndexScan_12 10000.00 cop table:t1, partition:p20090401, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_17 3333.33 root index:Selection_16 │ └─Selection_16 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_15 10000.00 cop table:t1, partition:p20090402, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_20 3333.33 root data:Selection_19 +│ └─IndexScan_15 10000.00 cop table:t1, partition:p20090402, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_20 3333.33 root index:Selection_19 │ └─Selection_19 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_18 10000.00 cop table:t1, partition:p20090403, range:[-inf,+inf], keep order:false, stats:pseudo -├─TableReader_23 3333.33 root data:Selection_22 +│ └─IndexScan_18 10000.00 cop table:t1, partition:p20090403, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +├─IndexReader_23 3333.33 root index:Selection_22 │ └─Selection_22 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) -│ └─TableScan_21 10000.00 cop table:t1, partition:p20090404, range:[-inf,+inf], keep order:false, stats:pseudo -└─TableReader_26 3333.33 root data:Selection_25 +│ └─IndexScan_21 10000.00 cop table:t1, partition:p20090404, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo +└─IndexReader_26 3333.33 root index:Selection_25 └─Selection_25 3333.33 cop gt(test.t1.b, 2009-04-02 23:59:58) - └─TableScan_24 10000.00 cop table:t1, partition:p20090405, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_24 10000.00 cop table:t1, partition:p20090405, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo DROP TABLE t1; # Test with DATETIME column NULL CREATE TABLE t1 ( diff --git a/cmd/explaintest/r/select.result b/cmd/explaintest/r/select.result index 143cf7cc28a9f..f7441cf82887a 100644 --- a/cmd/explaintest/r/select.result +++ b/cmd/explaintest/r/select.result @@ -255,9 +255,9 @@ create table t (a int, b int, c int, key idx(a, b, c)); explain select count(a) from t; id count task operator info StreamAgg_16 1.00 root funcs:count(col_0) -└─TableReader_17 1.00 root data:StreamAgg_8 +└─IndexReader_17 1.00 root index:StreamAgg_8 └─StreamAgg_8 1.00 cop funcs:count(test.t.a) - └─TableScan_15 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexScan_15 10000.00 cop table:t, index:a, b, c, range:[NULL,+inf], keep order:false, stats:pseudo select count(a) from t; count(a) 0 diff --git a/cmd/explaintest/r/subquery.result b/cmd/explaintest/r/subquery.result index 3d367f8bbeb07..c3974d52757e3 100644 --- a/cmd/explaintest/r/subquery.result +++ b/cmd/explaintest/r/subquery.result @@ -17,8 +17,8 @@ explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = id count task operator info Projection_11 5.00 root 9_aux_0 └─Apply_13 5.00 root CARTESIAN left outer semi join, inner:StreamAgg_20, other cond:eq(test.t.c, 7_col_0) - ├─TableReader_15 5.00 root data:TableScan_14 - │ └─TableScan_14 5.00 cop table:t, range:[-inf,+inf], keep order:false + ├─IndexReader_15 5.00 root index:IndexScan_14 + │ └─IndexScan_14 5.00 cop table:t, index:b, c, d, range:[NULL,+inf], keep order:false └─StreamAgg_20 1.00 root funcs:count(1) └─IndexJoin_23 0.50 root inner join, inner:TableReader_22, outer key:test.s.a, inner key:test.t1.a ├─IndexReader_27 1.00 root index:IndexScan_26 diff --git a/cmd/explaintest/r/topn_push_down.result b/cmd/explaintest/r/topn_push_down.result index 4d40a3b3b8caf..9deb403ecceca 100644 --- a/cmd/explaintest/r/topn_push_down.result +++ b/cmd/explaintest/r/topn_push_down.result @@ -223,8 +223,8 @@ explain select /*+ TIDB_INLJ(t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5 id count task operator info Limit_11 5.00 root offset:0, count:5 └─IndexJoin_15 5.00 root inner join, inner:IndexReader_14, outer key:test.t1.a, inner key:test.t2.a - ├─TableReader_17 4.00 root data:TableScan_16 - │ └─TableScan_16 4.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + ├─IndexReader_17 4.00 root index:IndexScan_16 + │ └─IndexScan_16 4.00 cop table:t1, index:a, range:[NULL,+inf], keep order:false, stats:pseudo └─IndexReader_14 10.00 root index:IndexScan_13 └─IndexScan_13 10.00 cop table:t2, index:a, range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo explain select /*+ TIDB_INLJ(t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; @@ -232,8 +232,8 @@ id count task operator info Limit_12 5.00 root offset:0, count:5 └─Selection_13 5.00 root isnull(test.t2.a) └─IndexJoin_17 5.00 root left outer join, inner:IndexReader_16, outer key:test.t1.a, inner key:test.t2.a - ├─TableReader_19 4.00 root data:TableScan_18 - │ └─TableScan_18 4.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo + ├─IndexReader_19 4.00 root index:IndexScan_18 + │ └─IndexScan_18 4.00 cop table:t1, index:a, range:[NULL,+inf], keep order:false, stats:pseudo └─IndexReader_16 10.00 root index:IndexScan_15 └─IndexScan_15 10.00 cop table:t2, index:a, range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo explain select /*+ TIDB_SMJ(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; @@ -256,17 +256,17 @@ Limit_12 5.00 root offset:0, count:5 explain select /*+ TIDB_HJ(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a limit 5; id count task operator info Limit_11 5.00 root offset:0, count:5 -└─HashLeftJoin_19 5.00 root inner join, inner:TableReader_24, equal:[eq(test.t1.a, test.t2.a)] - ├─TableReader_22 4.00 root data:TableScan_21 - │ └─TableScan_21 4.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo - └─TableReader_24 10000.00 root data:TableScan_23 - └─TableScan_23 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo +└─HashLeftJoin_19 5.00 root inner join, inner:IndexReader_24, equal:[eq(test.t1.a, test.t2.a)] + ├─IndexReader_22 4.00 root index:IndexScan_21 + │ └─IndexScan_21 4.00 cop table:t1, index:a, range:[NULL,+inf], keep order:false, stats:pseudo + └─IndexReader_24 10000.00 root index:IndexScan_23 + └─IndexScan_23 10000.00 cop table:t2, index:a, range:[NULL,+inf], keep order:false, stats:pseudo explain select /*+ TIDB_HJ(t1, t2) */ * from t t1 left join t t2 on t1.a = t2.a where t2.a is null limit 5; id count task operator info Limit_12 5.00 root offset:0, count:5 └─Selection_13 5.00 root isnull(test.t2.a) - └─HashLeftJoin_18 5.00 root left outer join, inner:TableReader_22, equal:[eq(test.t1.a, test.t2.a)] - ├─TableReader_20 4.00 root data:TableScan_19 - │ └─TableScan_19 4.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo - └─TableReader_22 10000.00 root data:TableScan_21 - └─TableScan_21 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo + └─HashLeftJoin_18 5.00 root left outer join, inner:IndexReader_22, equal:[eq(test.t1.a, test.t2.a)] + ├─IndexReader_20 4.00 root index:IndexScan_19 + │ └─IndexScan_19 4.00 cop table:t1, index:a, range:[NULL,+inf], keep order:false, stats:pseudo + └─IndexReader_22 10000.00 root index:IndexScan_21 + └─IndexScan_21 10000.00 cop table:t2, index:a, range:[NULL,+inf], keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/window_function.result b/cmd/explaintest/r/window_function.result index 3f4e6132897fe..6096ce1ab4023 100644 --- a/cmd/explaintest/r/window_function.result +++ b/cmd/explaintest/r/window_function.result @@ -6,8 +6,8 @@ explain select sum(a) over() from t; id count task operator info Projection_7 10000.00 root sum(a) over() └─Window_8 10000.00 root sum(cast(test.t.a)) over() - └─TableReader_10 10000.00 root data:TableScan_9 - └─TableScan_9 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo + └─IndexReader_10 10000.00 root index:IndexScan_9 + └─IndexScan_9 10000.00 cop table:t, index:a, range:[NULL,+inf], keep order:false, stats:pseudo explain select sum(a) over(partition by a) from t; id count task operator info Projection_7 10000.00 root sum(a) over(partition by a) diff --git a/docs/design/2019-04-11-indexmerge.md b/docs/design/2019-04-11-indexmerge.md index aa0108d62487a..14a0e7eb5e96a 100644 --- a/docs/design/2019-04-11-indexmerge.md +++ b/docs/design/2019-04-11-indexmerge.md @@ -1,48 +1,48 @@ -# Proposal: scan a table using IndexMerge -- Author(s) : WHU -- Last updated : May 10 -- Discussion at : - - -## Abstract - -The proposal proposes to use multiple indexes to scan a table if possible. In some cases, using multiple indexes will improve performance. - -## Background - -In present TiDB, a SQL statement with conditions involving multiple indexed attributes only uses one of the conditions as the index filter to build access condition, while others are regarded as table filters. Firstly, use index scan (at most one index) to get handles (rowid in TiDB). Then use the handles to get rows and check whether the rows satisfy the conditions of table filters. Some relational databases implement a table access path using multiple indexes. In some cases, this way will improve performance. - -We take an example to explain it. We define the table schema as : - -``` -CREATE TABLE t1 (a int, b int, c int); -CREATE INDEX t1a on t1(a); -CREATE INDEX t1b on t1(b); -CREATE INDEX t1c on t1(c); -``` -And use a test SQL statement `SELECT * FROM t1 where a < 2 or b > 50`. Currently, TiDB does a table scan and puts `a < 2 or b > 50` as a Selection on top of it. If the selectivity of `a < 2 ` and `b > 50` is low, a better approach would be using indexes on columns `a` and `b` to retrieve rows respectively, and applying a union operation on the result sets. - - -## Proposal -In short, we need to consider access paths using multiple indexes. - -### Planner -We propose to add new `IndexMergeReader / PhysicalIndexMergeReader` and `IndexMergeLookUpReader / PhysicalIndexMergeLookUpReader` operators. - -Now we just consider the following two kinds of queries: - -(1)Conditions in CNF, e.g, `select * from t1 where c1 and c2 and c3 and …` - +# Proposal: scan a table using IndexMerge +- Author(s) : WHU +- Last updated : May 10 +- Discussion at : + + +## Abstract + +The proposal proposes to use multiple indexes to scan a table if possible. In some cases, using multiple indexes will improve performance. + +## Background + +In present TiDB, a SQL statement with conditions involving multiple indexed attributes only uses one of the conditions as the index filter to build access condition, while others are regarded as table filters. Firstly, use index scan (at most one index) to get handles (rowid in TiDB). Then use the handles to get rows and check whether the rows satisfy the conditions of table filters. Some relational databases implement a table access path using multiple indexes. In some cases, this way will improve performance. + +We take an example to explain it. We define the table schema as : + +``` +CREATE TABLE t1 (a int, b int, c int); +CREATE INDEX t1a on t1(a); +CREATE INDEX t1b on t1(b); +CREATE INDEX t1c on t1(c); +``` +And use a test SQL statement `SELECT * FROM t1 where a < 2 or b > 50`. Currently, TiDB does a table scan and puts `a < 2 or b > 50` as a Selection on top of it. If the selectivity of `a < 2 ` and `b > 50` is low, a better approach would be using indexes on columns `a` and `b` to retrieve rows respectively, and applying a union operation on the result sets. + + +## Proposal +In short, we need to consider access paths using multiple indexes. + +### Planner +We propose to add new `IndexMergeReader / PhysicalIndexMergeReader` and `IndexMergeLookUpReader / PhysicalIndexMergeLookUpReader` operators. + +Now we just consider the following two kinds of queries: + +(1)Conditions in CNF, e.g, `select * from t1 where c1 and c2 and c3 and …` + In this form, each CNF item can be covered by a single index respectively. For example, if we have single column indexes for `t1.a`, `ta.b` and `t1.c` respectively, for SQL `select * from t1 where (a < 10 or a > 100) and b < 10 and c > 1000`, we can use all the three indexes to read the table handles. The result plan for it is like: - -``` -PhysicalIndexMergeLookUpReader(IndexMergeIntersect) - IndexScan(t1a) - IndexScan(t1b) - IndexScan(t1c) + +``` +PhysicalIndexMergeLookUpReader(IndexMergeIntersect) + IndexScan(t1a) + IndexScan(t1b) + IndexScan(t1c) TableScan ``` - + For the CNF items not covered by any index, we take them as table filters and convert them to selection on top of the scan node. For SQL `select * from t1 where (a < 10 or c >100) and b < 10`, only item `b < 10` can be used as index access condition, so we can only consider single index lookup reader. We set up a experiment for the CNF form to compare our demo implement with the master branch. The schema and test sql form we define are following: @@ -64,17 +64,17 @@ We load two million rows into `T200M` with one to two million sequence for all c CNF 200 -**Note:** `SELECTIVITY`is for the single column. - -(2) Conditions in DNF, e.g, `select * from t1 where c1 or c2 or c3 or …` - -In this form, every DNF item must be covered by a single index. If any DNF item cannot be covered by a single index, we cannot choose IndexMerge scan. For example, SQL `select * from t1 where a > 1 or ( b >1 and b <10)` will generate a possible plan like: - -``` -PhysicalIndexMergeLookUpReader(IndexMergeUnion) - IndexScan(t1a) - IndexScan(t1b) - TableScan +**Note:** `SELECTIVITY`is for the single column. + +(2) Conditions in DNF, e.g, `select * from t1 where c1 or c2 or c3 or …` + +In this form, every DNF item must be covered by a single index. If any DNF item cannot be covered by a single index, we cannot choose IndexMerge scan. For example, SQL `select * from t1 where a > 1 or ( b >1 and b <10)` will generate a possible plan like: + +``` +PhysicalIndexMergeLookUpReader(IndexMergeUnion) + IndexScan(t1a) + IndexScan(t1b) + TableScan ``` We set up a experiment for the DNF form to compare our demo implement with the master branch. The schema and test sql form we define are following: @@ -87,235 +87,235 @@ Table Schema: Test SQL Form: SELECT * FROM T200 WHERE a < $1 OR b > $2; -``` +``` We load two million rows into `T200` with one to two million sequence for all columns. We alter the value of `$1` and `$2` in test sql form to obtain the accurate selectivities. The result can be seen in the following graph: DNF 200 - - -We design PhysicalIndexMergeLookUpReader structure as: - -``` -// PhysicalIndexMergeLookUpReader -type PhysicalIndexMergeLookUpReader struct { - physicalSchemaProducer - - //Follow two plans flat to construct executor pb. - IndexPlans []PhysicalPlan - TablePlans []PhysicalPlan - - indexPlans []PhysicalPlan - tablePlan PhysicalPlan - - IndexMergeType int -} -``` - - -- The field `IndexMergeType` indicates the operations on results of multiple index scans, and has the following possible values: - - 0: not an IndexMerge scan; - - 1: intersection operation on result sets, and with a table scan; - - 2: intersection operation on result sets, without the table scan; - - 3: union operation on result sets, must have a table scan; - + + +We design PhysicalIndexMergeLookUpReader structure as: + +``` +// PhysicalIndexMergeLookUpReader +type PhysicalIndexMergeLookUpReader struct { + physicalSchemaProducer + + //Follow two plans flat to construct executor pb. + IndexPlans []PhysicalPlan + TablePlans []PhysicalPlan + + indexPlans []PhysicalPlan + tablePlan PhysicalPlan + + IndexMergeType int +} +``` + + +- The field `IndexMergeType` indicates the operations on results of multiple index scans, and has the following possible values: + - 0: not an IndexMerge scan; + - 1: intersection operation on result sets, and with a table scan; + - 2: intersection operation on result sets, without the table scan; + - 3: union operation on result sets, must have a table scan; + In first version, we just take `PhysicalIndexMergeLookUpReader` and `PhysicalIndexMergeReader` together. - -### IndexMergePath Generate -Now, we first generate all possible IndexMergeOr paths, then generate possible IndexMergeIntersection path. - -``` -type IndexMergePath struct { - IndexPath[] - tableFilters - IndexMergeType -} -``` - - -``` -GetIndexMergeUnionPaths(IndexInfos, PushdownConditions){ - var results = nil - foreach cond in PushdownConditions { - if !isOrCondition(cond) { - continue - } - args = flatten(cond,'or') - foreach arg in args { - var indexAccessPaths, imPaths - // Common index paths would be merged later in `CreateIndexMergeUnionPath` - if isAndCondition(arg) { - andArgs = flatten(arg,'and') - indexAccessPaths = buildAccessPath(andArgs, IndexInfos) - } else { - tempArgs = []{arg} - indexAccessPaths = buildAccessPath(tempArgs, IndexInfos) - } - if indexAccessPaths == nil { - imPaths = nil - break - } - imPartialPath = GetIndexMergePartialPath(IndexInfos, indexAccessPaths) - imPaths = append(imPaths, imPartialPath) - } - if imPaths != nil { - possiblePath = CreateIndexMergeUnionPath(imPaths,PushdownConditions,con,IndexInfos) - results = append(results, possiblePath) - } - } - return results -} - - -buildAccessPath(Conditions, IndexInfos){ - var results - for index in IndexInfos { - res = detachCNFCondAndBuildRangeForIndex(Conditions, index, considerDNF = true) - if res.accessCondition = nil { - continue - } - indexPath = CreateIndexAccessPath(index, res) - results = append(results, indexPath) - } - return results -} - -// This function will get a best indexPath for a con from some alternative paths. -// now we just take the index which has more columns. -// for exmple: -// (1) -// index1(a,b,c) index2(a,b) index3(a) -// condition: a = 1 will choose index1; a = 1 and b = 2 will also choose index1 -// (2) -// index1(a) index2(b) -// condition: a = 1 and b = 1 -// random choose??? -GetIndexMergePartialPath(IndexInfos, indexAccessPaths) { -} - -// (1)maybe we will merge some indexPaths -// for example: index1(a) index2(b) -// condition : a < 1 or a > 2 or b < 1 or b > 10 -// imPaths will be [a<1,a>2,b<1,b>10] and we can merge it and get [a<1 or a >2 , b < 1 or b > 10] -// (2)IndexMergePath.tableFilters: -// <1> remove cond from PushdownConditions and the remain will be added to tableFitler. -// <2> after merge operation, if any indexPath's tableFilter is not nil, we should add it into tableFilters - -CreateIndexMergeUnionPath(imPaths,PushdownConditions,cond,IndexInfos) { -} - -``` - - -``` -GetIndexMergeIntersectionPaths(pushDownConditions, usedConditionsInOr, indexInfos) { - var partialPaths - - if len(pushDownConditions) - len(usedConditionsInOr) < 2 { - return nil - } - tableFilters := append(tableFilters, usedConditionsInOr...) - newConsiderConditions := remove(pushDownConditions, usedConditionsInOr) - for cond in newConsiderConditions { - indexPaths = buildAccessPath([]{cond}, indexInfos) - if indexPaths == nil { - tableFiltes = append(tableFilters,cond) - continue - } - indexPath := GetIndexMergePartialPath(indexPaths,indexInfos) - partialPaths = append(partialPaths, indexPath) - } - if len(partialPaths) < 2 { - return nil - } - return CreateIndexMergeIntersectionPath(partialPaths, tableFilters) -} - -// Now, we just use all path in partialPaths to generate a IndexMergeIntersection. -// We also need to merge possible paths. -// For example: -// index: ix1(a) -// condition: a > 1 and a < 10 -// we will get two partial paths and they all use index ix1. -// IndexMergePath.tableFilters: -// <1> tableFilters -// <2> after merge operation, if any indexPath's tableFilter is not nil, we -// should add indexPath’s tableFilter into IndexMergePath.tableFilters -CreateIndexMergeIntersectionPath(partialPaths, tableFilters) { -} - -``` - -### Executor -Graph bellow illustrates execution of IndexMerge scan. -Execution Model - -Every index plan in `PhysicalIndexMergeLookUpReader` will start an `IndexWorker` to execute the IndexScan plan and send handles to AndOrWorker. AndOrWorker is responsible for doing set operations (and, or) to get final handles. Then `AndOrWoker` sends final handles to `TableWokers` to get rows from TiKV. - -We can take some tricks to make execution at pipeline mode without considering the order. - - -(1) IndexMergeIntersection + +### IndexMergePath Generate +Now, we first generate all possible IndexMergeOr paths, then generate possible IndexMergeIntersection path. + +``` +type IndexMergePath struct { + IndexPath[] + tableFilters + IndexMergeType +} +``` + + +``` +GetIndexMergeUnionPaths(IndexInfos, PushdownConditions){ + var results = nil + foreach cond in PushdownConditions { + if !isOrCondition(cond) { + continue + } + args = flatten(cond,'or') + foreach arg in args { + var indexAccessPaths, imPaths + // Common index paths would be merged later in `CreateIndexMergeUnionPath` + if isAndCondition(arg) { + andArgs = flatten(arg,'and') + indexAccessPaths = buildAccessPath(andArgs, IndexInfos) + } else { + tempArgs = []{arg} + indexAccessPaths = buildAccessPath(tempArgs, IndexInfos) + } + if indexAccessPaths == nil { + imPaths = nil + break + } + imPartialPath = GetIndexMergePartialPath(IndexInfos, indexAccessPaths) + imPaths = append(imPaths, imPartialPath) + } + if imPaths != nil { + possiblePath = CreateIndexMergeUnionPath(imPaths,PushdownConditions,con,IndexInfos) + results = append(results, possiblePath) + } + } + return results +} + + +buildAccessPath(Conditions, IndexInfos){ + var results + for index in IndexInfos { + res = detachCNFCondAndBuildRangeForIndex(Conditions, index, considerDNF = true) + if res.accessCondition = nil { + continue + } + indexPath = CreateIndexAccessPath(index, res) + results = append(results, indexPath) + } + return results +} + +// This function will get a best indexPath for a con from some alternative paths. +// now we just take the index which has more columns. +// for exmple: +// (1) +// index1(a,b,c) index2(a,b) index3(a) +// condition: a = 1 will choose index1; a = 1 and b = 2 will also choose index1 +// (2) +// index1(a) index2(b) +// condition: a = 1 and b = 1 +// random choose??? +GetIndexMergePartialPath(IndexInfos, indexAccessPaths) { +} + +// (1)maybe we will merge some indexPaths +// for example: index1(a) index2(b) +// condition : a < 1 or a > 2 or b < 1 or b > 10 +// imPaths will be [a<1,a>2,b<1,b>10] and we can merge it and get [a<1 or a >2 , b < 1 or b > 10] +// (2)IndexMergePath.tableFilters: +// <1> remove cond from PushdownConditions and the remain will be added to tableFitler. +// <2> after merge operation, if any indexPath's tableFilter is not nil, we should add it into tableFilters + +CreateIndexMergeUnionPath(imPaths,PushdownConditions,cond,IndexInfos) { +} + +``` + + +``` +GetIndexMergeIntersectionPaths(pushDownConditions, usedConditionsInOr, indexInfos) { + var partialPaths + + if len(pushDownConditions) - len(usedConditionsInOr) < 2 { + return nil + } + tableFilters := append(tableFilters, usedConditionsInOr...) + newConsiderConditions := remove(pushDownConditions, usedConditionsInOr) + for cond in newConsiderConditions { + indexPaths = buildAccessPath([]{cond}, indexInfos) + if indexPaths == nil { + tableFiltes = append(tableFilters,cond) + continue + } + indexPath := GetIndexMergePartialPath(indexPaths,indexInfos) + partialPaths = append(partialPaths, indexPath) + } + if len(partialPaths) < 2 { + return nil + } + return CreateIndexMergeIntersectionPath(partialPaths, tableFilters) +} + +// Now, we just use all path in partialPaths to generate a IndexMergeIntersection. +// We also need to merge possible paths. +// For example: +// index: ix1(a) +// condition: a > 1 and a < 10 +// we will get two partial paths and they all use index ix1. +// IndexMergePath.tableFilters: +// <1> tableFilters +// <2> after merge operation, if any indexPath's tableFilter is not nil, we +// should add indexPath’s tableFilter into IndexMergePath.tableFilters +CreateIndexMergeIntersectionPath(partialPaths, tableFilters) { +} + +``` + +### Executor +Graph bellow illustrates execution of IndexMerge scan. +Execution Model + +Every index plan in `PhysicalIndexMergeLookUpReader` will start an `IndexWorker` to execute the IndexScan plan and send handles to AndOrWorker. AndOrWorker is responsible for doing set operations (and, or) to get final handles. Then `AndOrWoker` sends final handles to `TableWokers` to get rows from TiKV. + +We can take some tricks to make execution at pipeline mode without considering the order. + + +(1) IndexMergeIntersection - IndexMergeIntersection - We take an example to explain it. Use set1 to record rowids which are returned by ix1 but not sent to tableWorker. Use set2 to record the same thing for ix2. -If new rowid comes from ix1, first we check if it is in set2. If so, we delete it from set2 and send it to tableWorker. Otherwise, we add it into set1. For the above figure, we use the following table to show the processing. - -| new rowid | set1 | set2 | sent to TableWorker | -| :------:| :------: | :------: | :------: | -| 2(ix1) | [2] | [ ] | [ ] | -| 1(ix2) | [2] | [1] | [ ] | -| 5(ix1) | [2,5] |[1] | [ ] | -| 5(ix2) | [2] | [1] | [5] | -| 7(ix1) | [2,7] |[1] | [ ] | -| 2(ix2) | [7] | [1] | [2] | - - - -(2) IndexMergeUnion - - - We take a structure(we call it set) to record which rowids are accessed. If a new rowid returned by IndexScan, check if it is in set. If in it, we just skip it. Otherwise, we add it into set and send it to tableWorker. - -### Cost Model -Cost model will consider three factors: IO, CPU, and Network. - -- `IndexMergeType` = 1 - - IO Cost = (totalRowCount + mergedRowCount) * scanFactor - - Network Cost = (totalRowCount + mergedRowCount) * networkFactor - - Cpu Memory Cost = totalRowCount * cpuFactor + totalRowCount * memoryFactor - -- `IndexMergeType` = 2 - - IO Cost = (totalRowCount) * scanFactor - - Network Cost = totalRowCount * networkFactor - - Cpu Memory Cost = totalRowCount * cpuFactor + totalRowCount * memoryFactor - -- `IndexMergeType` = 3 - - IO Cost = (totalRowCount + mergedRowCount) * scanFactor - - Network Cost = (totalRowCount + mergedRowCount) * networkFactor - - Cpu Memory Cost = totalRowCount * cpuFactor + mergedRowCount * memoryFactor - - -**Note**: - -- totalRowCount: sum of handles collected from every index scan. - -- mergedRowCount: number of handles after set operating. - -## Compatibility -This proposal has no effect on the compatibility. - -## Implementation -1. Implement planner operators -1. Enhance `explain` to display the plan -3. Implement executor operators -4. Testing + IndexMergeIntersection + We take an example to explain it. Use set1 to record rowids which are returned by ix1 but not sent to tableWorker. Use set2 to record the same thing for ix2. +If new rowid comes from ix1, first we check if it is in set2. If so, we delete it from set2 and send it to tableWorker. Otherwise, we add it into set1. For the above figure, we use the following table to show the processing. + +| new rowid | set1 | set2 | sent to TableWorker | +| :------:| :------: | :------: | :------: | +| 2(ix1) | [2] | [ ] | [ ] | +| 1(ix2) | [2] | [1] | [ ] | +| 5(ix1) | [2,5] |[1] | [ ] | +| 5(ix2) | [2] | [1] | [5] | +| 7(ix1) | [2,7] |[1] | [ ] | +| 2(ix2) | [7] | [1] | [2] | + + + +(2) IndexMergeUnion + + + We take a structure(we call it set) to record which rowids are accessed. If a new rowid returned by IndexScan, check if it is in set. If in it, we just skip it. Otherwise, we add it into set and send it to tableWorker. + +### Cost Model +Cost model will consider three factors: IO, CPU, and Network. + +- `IndexMergeType` = 1 + + IO Cost = (totalRowCount + mergedRowCount) * scanFactor + + Network Cost = (totalRowCount + mergedRowCount) * networkFactor + + Cpu Memory Cost = totalRowCount * cpuFactor + totalRowCount * memoryFactor + +- `IndexMergeType` = 2 + + IO Cost = (totalRowCount) * scanFactor + + Network Cost = totalRowCount * networkFactor + + Cpu Memory Cost = totalRowCount * cpuFactor + totalRowCount * memoryFactor + +- `IndexMergeType` = 3 + + IO Cost = (totalRowCount + mergedRowCount) * scanFactor + + Network Cost = (totalRowCount + mergedRowCount) * networkFactor + + Cpu Memory Cost = totalRowCount * cpuFactor + mergedRowCount * memoryFactor + + +**Note**: + +- totalRowCount: sum of handles collected from every index scan. + +- mergedRowCount: number of handles after set operating. + +## Compatibility +This proposal has no effect on the compatibility. + +## Implementation +1. Implement planner operators +1. Enhance `explain` to display the plan +3. Implement executor operators +4. Testing diff --git a/executor/admin_test.go b/executor/admin_test.go index 843d39a67c239..4d59ebb926b81 100644 --- a/executor/admin_test.go +++ b/executor/admin_test.go @@ -145,7 +145,7 @@ func (s *testSuite2) TestAdminRecoverIndex(c *C) { r = tk.MustQuery("SELECT COUNT(*) FROM admin_test USE INDEX(c2)") r.Check(testkit.Rows("0")) - r = tk.MustQuery("SELECT COUNT(*) FROM admin_test") + r = tk.MustQuery("SELECT COUNT(*) FROM admin_test USE INDEX()") r.Check(testkit.Rows("5")) r = tk.MustQuery("admin recover index admin_test c2") @@ -380,7 +380,7 @@ func (s *testSuite2) TestAdminCleanupIndexMore(c *C) { c.Assert(err, NotNil) err = tk.ExecToErr("admin check index admin_test c2") c.Assert(err, NotNil) - r := tk.MustQuery("SELECT COUNT(*) FROM admin_test") + r := tk.MustQuery("SELECT COUNT(*) FROM admin_test USE INDEX()") r.Check(testkit.Rows("3")) r = tk.MustQuery("SELECT COUNT(*) FROM admin_test USE INDEX(c1)") r.Check(testkit.Rows("2003")) diff --git a/executor/join_test.go b/executor/join_test.go index df027e780ab5d..6c2211538be29 100644 --- a/executor/join_test.go +++ b/executor/join_test.go @@ -832,8 +832,8 @@ func (s *testSuite2) TestIndexLookupJoin(c *C) { tk.MustExec("CREATE INDEX idx_s_a ON s(`a`)") tk.MustExec("INSERT INTO s VALUES (-277544960, 'fpnndsjo') , (2, 'kfpnndsjof') , (2, 'vtdiockfpn'), (-277544960, 'fpnndsjo') , (2, 'kfpnndsjof') , (6, 'ckfp')") tk.MustQuery("select /*+ TIDB_INLJ(t, s) */ t.a from t join s on t.a = s.a").Check(testkit.Rows("-277544960", "-277544960")) - tk.MustQuery("select /*+ TIDB_INLJ(t, s) */ t.a from t left join s on t.a = s.a").Check(testkit.Rows("148307968", "-1327693824", "-277544960", "-277544960")) - tk.MustQuery("select /*+ TIDB_INLJ(t, s) */ t.a from t right join s on t.a = s.a").Check(testkit.Rows("-277544960", "", "", "-277544960", "", "")) + tk.MustQuery("select /*+ TIDB_INLJ(t, s) */ t.a from t left join s on t.a = s.a").Check(testkit.Rows("-1327693824", "-277544960", "-277544960", "148307968")) + tk.MustQuery("select /*+ TIDB_INLJ(t, s) */ t.a from t right join s on t.a = s.a").Check(testkit.Rows("-277544960", "-277544960", "", "", "", "")) tk.MustExec("DROP TABLE IF EXISTS t;") tk.MustExec("CREATE TABLE t(a BIGINT PRIMARY KEY, b BIGINT);") tk.MustExec("INSERT INTO t VALUES(1, 2);") diff --git a/executor/union_scan_test.go b/executor/union_scan_test.go index 7fc90083cf144..bdb56413a85c4 100644 --- a/executor/union_scan_test.go +++ b/executor/union_scan_test.go @@ -28,7 +28,7 @@ func (s *testSuite4) TestDirtyTransaction(c *C) { tk.MustQuery("select * from t").Check(testkit.Rows("2 3", "4 8", "6 8")) tk.MustExec("insert t values (1, 5), (3, 4), (7, 6)") tk.MustQuery("select * from information_schema.columns") - tk.MustQuery("select * from t").Check(testkit.Rows("1 5", "2 3", "3 4", "4 8", "6 8", "7 6")) + tk.MustQuery("select * from t").Check(testkit.Rows("2 3", "3 4", "1 5", "7 6", "4 8", "6 8")) tk.MustQuery("select * from t where a = 1").Check(testkit.Rows("1 5")) tk.MustQuery("select * from t order by a desc").Check(testkit.Rows("7 6", "6 8", "4 8", "3 4", "2 3", "1 5")) tk.MustQuery("select * from t order by b, a").Check(testkit.Rows("2 3", "3 4", "1 5", "7 6", "4 8", "6 8")) @@ -36,13 +36,13 @@ func (s *testSuite4) TestDirtyTransaction(c *C) { tk.MustQuery("select b from t where b = 8 order by b desc").Check(testkit.Rows("8", "8")) // Delete a snapshot row and a dirty row. tk.MustExec("delete from t where a = 2 or a = 3") - tk.MustQuery("select * from t").Check(testkit.Rows("1 5", "4 8", "6 8", "7 6")) + tk.MustQuery("select * from t").Check(testkit.Rows("1 5", "7 6", "4 8", "6 8")) tk.MustQuery("select * from t order by a desc").Check(testkit.Rows("7 6", "6 8", "4 8", "1 5")) tk.MustQuery("select * from t order by b, a").Check(testkit.Rows("1 5", "7 6", "4 8", "6 8")) tk.MustQuery("select * from t order by b desc, a desc").Check(testkit.Rows("6 8", "4 8", "7 6", "1 5")) // Add deleted row back. tk.MustExec("insert t values (2, 3), (3, 4)") - tk.MustQuery("select * from t").Check(testkit.Rows("1 5", "2 3", "3 4", "4 8", "6 8", "7 6")) + tk.MustQuery("select * from t").Check(testkit.Rows("2 3", "3 4", "1 5", "7 6", "4 8", "6 8")) tk.MustQuery("select * from t order by a desc").Check(testkit.Rows("7 6", "6 8", "4 8", "3 4", "2 3", "1 5")) tk.MustQuery("select * from t order by b, a").Check(testkit.Rows("2 3", "3 4", "1 5", "7 6", "4 8", "6 8")) tk.MustQuery("select * from t order by b desc, a desc").Check(testkit.Rows("6 8", "4 8", "7 6", "1 5", "3 4", "2 3")) diff --git a/planner/core/cbo_test.go b/planner/core/cbo_test.go index 32a7357c70957..8dab6a8829639 100644 --- a/planner/core/cbo_test.go +++ b/planner/core/cbo_test.go @@ -915,13 +915,13 @@ func (s *testAnalyzeSuite) TestIssue9562(c *C) { tk.MustExec("create table t(a int, b int, index idx_ab(a, b))") tk.MustQuery("explain select * from t t1 join t t2 where t1.b = t2.b and t2.b is null").Check(testkit.Rows( "Projection_7 0.00 root test.t1.a, test.t1.b, test.t2.a, test.t2.b", - "└─HashRightJoin_9 0.00 root inner join, inner:TableReader_12, equal:[eq(test.t2.b, test.t1.b)]", - " ├─TableReader_12 0.00 root data:Selection_11", + "└─HashRightJoin_9 0.00 root inner join, inner:IndexReader_12, equal:[eq(test.t2.b, test.t1.b)]", + " ├─IndexReader_12 0.00 root index:Selection_11", " │ └─Selection_11 0.00 cop isnull(test.t2.b), not(isnull(test.t2.b))", - " │ └─TableScan_10 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo", - " └─TableReader_15 9990.00 root data:Selection_14", + " │ └─IndexScan_10 10000.00 cop table:t2, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo", + " └─IndexReader_15 9990.00 root index:Selection_14", " └─Selection_14 9990.00 cop not(isnull(test.t1.b))", - " └─TableScan_13 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo", + " └─IndexScan_13 10000.00 cop table:t1, index:a, b, range:[NULL,+inf], keep order:false, stats:pseudo", )) } diff --git a/planner/core/find_best_task.go b/planner/core/find_best_task.go index 40e20ea43287d..2be6c5982ed22 100644 --- a/planner/core/find_best_task.go +++ b/planner/core/find_best_task.go @@ -211,6 +211,18 @@ type candidatePath struct { isMatchProp bool } +// getScanType converts the scan type to int, the higher the better. +// DoubleScan -> 0, TableScan -> 1, IndexScan -> 2. +func getScanTypeScore(p *candidatePath) int { + if !p.isSingleScan { + return 0 + } + if p.path.isTablePath { + return 1 + } + return 2 +} + // compareColumnSet will compares the two set. The last return value is used to indicate // if they are comparable, it is false when both two sets have columns that do not occur in the other. // When the second return value is true, the value of first: @@ -241,10 +253,20 @@ func compareBool(l, r bool) int { return 1 } +func compareInt(l, r int) int { + if l == r { + return 0 + } + if l < r { + return -1 + } + return 1 +} + // compareCandidates is the core of skyline pruning. It compares the two candidate paths on three dimensions: // (1): the set of columns that occurred in the access condition, // (2): whether or not it matches the physical property -// (3): does it require a double scan. +// (3): whether the candidate is a IndexScan or TableScan or DoubleScan. (IndexScan > TableScan > DoubleScan) // If `x` is not worse than `y` at all factors, // and there exists one factor that `x` is better than `y`, then `x` is better than `y`. func compareCandidates(lhs, rhs *candidatePath) int { @@ -252,7 +274,7 @@ func compareCandidates(lhs, rhs *candidatePath) int { if !comparable { return 0 } - scanResult := compareBool(lhs.isSingleScan, rhs.isSingleScan) + scanResult := compareInt(getScanTypeScore(lhs), getScanTypeScore(rhs)) matchResult := compareBool(lhs.isMatchProp, rhs.isMatchProp) sum := setsResult + scanResult + matchResult if setsResult >= 0 && scanResult >= 0 && matchResult >= 0 && sum > 0 { @@ -305,11 +327,12 @@ func (ds *DataSource) skylinePruning(prop *property.PhysicalProperty) []*candida var currentCandidate *candidatePath if path.isTablePath { currentCandidate = ds.getTableCandidate(path, prop) - } else if len(path.accessConds) > 0 || !prop.IsEmpty() || path.forced { - // We will use index to generate physical plan if: - // this path's access cond is not nil or - // we have prop to match or - // this index is forced to choose. + } else if len(path.accessConds) > 0 || !prop.IsEmpty() || path.forced || isCoveringIndex(ds.schema.Columns, path.index.Columns, ds.tableInfo.PKIsHandle) { + // We will use index to generate physical plan if any of the following conditions is satisfied: + // 1. This path's access cond is not nil. + // 2. We have a non-empty prop to match. + // 3. This index is forced to choose. + // 4. The needed columns are all covered by index columns(and handleCol). currentCandidate = ds.getIndexCandidate(path, prop) } else { continue diff --git a/planner/core/logical_plan_test.go b/planner/core/logical_plan_test.go index 264cf7745b8e2..e1dfc14302692 100644 --- a/planner/core/logical_plan_test.go +++ b/planner/core/logical_plan_test.go @@ -2237,7 +2237,7 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { }, { sql: "select a, avg(a+1) over(partition by (a+1)) from t", - result: "TableReader(Table(t))->Projection->Sort->Window(avg(cast(2_proj_window_3)) over(partition by 2_proj_window_2))->Projection", + result: "IndexReader(Index(t.c_d_e)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(2_proj_window_3)) over(partition by 2_proj_window_2))->Projection", }, { sql: "select a, avg(a) over(order by a asc, b desc) from t order by a asc, b desc", @@ -2257,7 +2257,7 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { }, { sql: "select sum(avg(a)) over() from t", - result: "TableReader(Table(t)->StreamAgg)->StreamAgg->Window(sum(sel_agg_2) over())->Projection", + result: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->StreamAgg)->StreamAgg->Window(sum(sel_agg_2) over())->Projection", }, { sql: "select b from t order by(sum(a) over())", @@ -2273,7 +2273,7 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { }, { sql: "select a from t having (select sum(a) over() as w from t tt where a > t.a)", - result: "Apply{TableReader(Table(t))->TableReader(Table(t)->Sel([gt(test.tt.a, test.t.a)]))->Window(sum(cast(test.tt.a)) over())->MaxOneRow->Sel([w])}->Projection", + result: "Apply{IndexReader(Index(t.c_d_e)[[NULL,+inf]])->IndexReader(Index(t.c_d_e)[[NULL,+inf]]->Sel([gt(test.tt.a, test.t.a)]))->Window(sum(cast(test.tt.a)) over())->MaxOneRow->Sel([w])}->Projection", }, { sql: "select avg(a) over() as w from t having w > 1", @@ -2305,7 +2305,7 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { }, { sql: "select sum(a) over w from t window w as (rows between 1 preceding AND 1 following)", - result: "TableReader(Table(t))->Window(sum(cast(test.t.a)) over(rows between 1 preceding and 1 following))->Projection", + result: "IndexReader(Index(t.c_d_e)[[NULL,+inf]])->Window(sum(cast(test.t.a)) over(rows between 1 preceding and 1 following))->Projection", }, { sql: "select sum(a) over(w order by b) from t window w as (order by a)", @@ -2373,7 +2373,7 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { }, { sql: "select row_number() over(rows between 1 preceding and 1 following) from t", - result: "TableReader(Table(t))->Window(row_number() over())->Projection", + result: "IndexReader(Index(t.c_d_e)[[NULL,+inf]])->Window(row_number() over())->Projection", }, { sql: "select avg(b), max(avg(b)) over(rows between 1 preceding and 1 following) max from t group by c", @@ -2397,7 +2397,7 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { }, { sql: "select ntile(null) over() from t", - result: "TableReader(Table(t))->Window(ntile() over())->Projection", + result: "IndexReader(Index(t.c_d_e)[[NULL,+inf]])->Window(ntile() over())->Projection", }, { sql: "select avg(a) over w from t window w as(partition by b)", @@ -2572,6 +2572,10 @@ func (s *testPlanSuite) TestSkylinePruning(c *C) { sql: "select * from t where f > 1 and g > 1", result: "PRIMARY_KEY,f,g,f_g", }, + { + sql: "select count(1) from t", + result: "c_d_e,f,g,f_g,c_d_e_str,e_d_c_str_prefix", + }, } ctx := context.TODO() for i, tt := range tests { diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index e1f7e3bdf4f27..a6c65e1e8c25c 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -126,7 +126,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderSimpleCase(c *C) { // Test Limit push down in table single read. { sql: "select c from t limit 1", - best: "TableReader(Table(t)->Limit)->Limit", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->Limit)->Limit", }, // Test Limit push down in index single read. { @@ -212,7 +212,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderSimpleCase(c *C) { }, { sql: "select lead(a, 1) over (partition by null) as c from t", - best: "TableReader(Table(t))->Window(lead(test.t.a, 1) over())->Projection", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]])->Window(lead(test.t.a, 1) over())->Projection", }, } for i, tt := range tests { @@ -375,7 +375,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderJoin(c *C) { // Test Index Join + SingleRead. { sql: "select /*+ TIDB_INLJ(t2) */ t1.a , t2.a from t t1, t t2 where t1.a = t2.c", - best: "IndexJoin{TableReader(Table(t))->IndexReader(Index(t.c_d_e)[[NULL,+inf]])}(test.t1.a,test.t2.c)->Projection", + best: "IndexJoin{IndexReader(Index(t.c_d_e)[[NULL,+inf]])->IndexReader(Index(t.c_d_e)[[NULL,+inf]])}(test.t1.a,test.t2.c)->Projection", }, // Test Index Join + Order by. { @@ -390,7 +390,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderJoin(c *C) { // Test Index Join + TableScan + Rotate. { sql: "select /*+ TIDB_INLJ(t1) */ t1.a , t2.a from t t1, t t2 where t1.a = t2.c", - best: "IndexJoin{TableReader(Table(t))->TableReader(Table(t))}(test.t2.c,test.t1.a)->Projection", + best: "IndexJoin{TableReader(Table(t))->IndexReader(Index(t.c_d_e)[[NULL,+inf]])}(test.t2.c,test.t1.a)->Projection", }, // Test Index Join + OuterJoin + TableScan. { @@ -419,7 +419,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderJoin(c *C) { // Test Semi Join hint fail. { sql: "select /*+ TIDB_INLJ(t1) */ * from t t1 where t1.a in (select a from t t2)", - best: "IndexJoin{TableReader(Table(t))->TableReader(Table(t))}(test.t2.a,test.t1.a)->Projection", + best: "IndexJoin{TableReader(Table(t))->IndexReader(Index(t.c_d_e)[[NULL,+inf]])}(test.t2.a,test.t1.a)->Projection", }, { sql: "select /*+ TIDB_INLJ(t2) */ * from t t1 join t t2 where t1.c=t2.c and t1.f=t2.f", @@ -489,11 +489,11 @@ func (s *testPlanSuite) TestDAGPlanBuilderSubquery(c *C) { // Test join key with cast. { sql: "select * from t where exists (select s.a from t s having sum(s.a) = t.a )", - best: "LeftHashJoin{TableReader(Table(t))->Projection->TableReader(Table(t)->StreamAgg)->StreamAgg}(cast(test.t.a),sel_agg_1)->Projection", + best: "LeftHashJoin{TableReader(Table(t))->Projection->IndexReader(Index(t.c_d_e)[[NULL,+inf]]->StreamAgg)->StreamAgg}(cast(test.t.a),sel_agg_1)->Projection", }, { sql: "select * from t where exists (select s.a from t s having sum(s.a) = t.a ) order by t.a", - best: "LeftHashJoin{TableReader(Table(t))->Projection->TableReader(Table(t)->StreamAgg)->StreamAgg}(cast(test.t.a),sel_agg_1)->Projection->Sort", + best: "LeftHashJoin{TableReader(Table(t))->Projection->IndexReader(Index(t.c_d_e)[[NULL,+inf]]->StreamAgg)->StreamAgg}(cast(test.t.a),sel_agg_1)->Projection->Sort", }, // FIXME: Report error by resolver. //{ @@ -517,15 +517,15 @@ func (s *testPlanSuite) TestDAGPlanBuilderSubquery(c *C) { // Test Apply. { sql: "select t.c in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t", - best: "Apply{TableReader(Table(t))->IndexJoin{TableReader(Table(t))->TableReader(Table(t)->Sel([eq(test.t1.a, test.t.a)]))}(test.s.a,test.t1.a)->StreamAgg}->Projection", + best: "Apply{IndexReader(Index(t.c_d_e)[[NULL,+inf]])->IndexJoin{TableReader(Table(t))->TableReader(Table(t)->Sel([eq(test.t1.a, test.t.a)]))}(test.s.a,test.t1.a)->StreamAgg}->Projection", }, { sql: "select (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t", - best: "LeftHashJoin{TableReader(Table(t))->MergeInnerJoin{TableReader(Table(t))->TableReader(Table(t))}(test.s.a,test.t1.a)->StreamAgg}(test.t.a,test.s.a)->Projection->Projection", + best: "LeftHashJoin{IndexReader(Index(t.c_d_e)[[NULL,+inf]])->MergeInnerJoin{TableReader(Table(t))->TableReader(Table(t))}(test.s.a,test.t1.a)->StreamAgg}(test.t.a,test.s.a)->Projection->Projection", }, { sql: "select (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t order by t.a", - best: "LeftHashJoin{TableReader(Table(t))->MergeInnerJoin{TableReader(Table(t))->TableReader(Table(t))}(test.s.a,test.t1.a)->StreamAgg}(test.t.a,test.s.a)->Projection->Sort->Projection", + best: "LeftHashJoin{IndexReader(Index(t.c_d_e)[[NULL,+inf]])->MergeInnerJoin{TableReader(Table(t))->TableReader(Table(t))}(test.s.a,test.t1.a)->StreamAgg}(test.t.a,test.s.a)->Projection->Sort->Projection", }, } for _, tt := range tests { @@ -965,7 +965,7 @@ func (s *testPlanSuite) TestDAGPlanBuilderAgg(c *C) { }, { sql: "select sum(d) from t", - best: "TableReader(Table(t)->StreamAgg)->StreamAgg", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->StreamAgg)->StreamAgg", }, } for _, tt := range tests { @@ -1026,7 +1026,7 @@ func (s *testPlanSuite) TestRefine(c *C) { }, { sql: "select a from t where d <= 5 and d > 3", - best: "TableReader(Table(t)->Sel([le(test.t.d, 5) gt(test.t.d, 3)]))->Projection", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->Sel([le(test.t.d, 5) gt(test.t.d, 3)]))->Projection", }, { sql: "select a from t where c between 1 and 2", @@ -1058,7 +1058,7 @@ func (s *testPlanSuite) TestRefine(c *C) { }, { sql: "select a from t where not a", - best: "TableReader(Table(t)->Sel([not(test.t.a)]))", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->Sel([not(test.t.a)]))", }, { sql: "select a from t where c in (1)", @@ -1094,7 +1094,7 @@ func (s *testPlanSuite) TestRefine(c *C) { }, { sql: "select a from t where d in (1, 2, 3)", - best: "TableReader(Table(t)->Sel([in(test.t.d, 1, 2, 3)]))->Projection", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->Sel([in(test.t.d, 1, 2, 3)]))->Projection", }, { sql: "select a from t where c not in (1)", @@ -1123,7 +1123,7 @@ func (s *testPlanSuite) TestRefine(c *C) { }, { sql: "select a from t where c_str like '_abc'", - best: "TableReader(Table(t)->Sel([like(test.t.c_str, _abc, 92)]))->Projection", + best: "IndexReader(Index(t.c_d_e_str)[[NULL,+inf]]->Sel([like(test.t.c_str, _abc, 92)]))->Projection", }, { sql: `select a from t where c_str like 'abc%'`, @@ -1192,7 +1192,7 @@ func (s *testPlanSuite) TestRefine(c *C) { }, { sql: `select a from t where c = 'hanfei'`, - best: "TableReader(Table(t))->Sel([eq(cast(test.t.c), cast(hanfei))])->Projection", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]])->Sel([eq(cast(test.t.c), cast(hanfei))])->Projection", }, } for _, tt := range tests { @@ -1247,12 +1247,12 @@ func (s *testPlanSuite) TestAggEliminater(c *C) { // If max/min contains scalar function, we can still do transformation. { sql: "select max(a+1) from t;", - best: "TableReader(Table(t)->Sel([not(isnull(plus(test.t.a, 1)))])->TopN([plus(test.t.a, 1) true],0,1))->Projection->TopN([col_1 true],0,1)->Projection->Projection->StreamAgg", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->Sel([not(isnull(plus(test.t.a, 1)))])->TopN([plus(test.t.a, 1) true],0,1))->Projection->TopN([col_1 true],0,1)->Projection->Projection->StreamAgg", }, // Do nothing to max+min. { sql: "select max(a), min(a) from t;", - best: "TableReader(Table(t)->StreamAgg)->StreamAgg", + best: "IndexReader(Index(t.c_d_e)[[NULL,+inf]]->StreamAgg)->StreamAgg", }, // Do nothing to max with groupby. { @@ -1361,7 +1361,7 @@ func (s *testPlanSuite) TestIndexJoinUnionScan(c *C) { // Test Index Join + UnionScan + IndexScan. { sql: "select /*+ TIDB_INLJ(t1, t2) */ t1.a , t2.c from t t1, t t2 where t1.a = t2.c", - best: "IndexJoin{TableReader(Table(t))->UnionScan([])->IndexReader(Index(t.c_d_e)[[NULL,+inf]])->UnionScan([])}(test.t1.a,test.t2.c)->Projection", + best: "IndexJoin{IndexReader(Index(t.c_d_e)[[NULL,+inf]])->UnionScan([])->IndexReader(Index(t.c_d_e)[[NULL,+inf]])->UnionScan([])}(test.t1.a,test.t2.c)->Projection", is: s.is, }, // Index Join + Union Scan + Union All is not supported now. @@ -1542,12 +1542,12 @@ func (s *testPlanSuite) TestIndexJoinHint(c *C) { }, { sql: "select /*+ TIDB_INLJ(t1) */ t1.b, t2.a from t t1, t t2 where t1.b = t2.a;", - best: "LeftHashJoin{TableReader(Table(t))->TableReader(Table(t))}(test.t1.b,test.t2.a)", + best: "LeftHashJoin{TableReader(Table(t))->IndexReader(Index(t.c_d_e)[[NULL,+inf]])}(test.t1.b,test.t2.a)", warning: "[planner:1815]Optimizer Hint /*+ TIDB_INLJ(t1) */ is inapplicable", }, { sql: "select /*+ TIDB_INLJ(t2) */ t1.b, t2.a from t2 t1, t2 t2 where t1.b=t2.b and t2.c=-1;", - best: "IndexJoin{IndexReader(Index(t2.b)[[NULL,+inf]])->TableReader(Table(t2)->Sel([eq(test.t2.c, -1)]))}(test.t2.b,test.t1.b)->Projection", + best: "IndexJoin{IndexReader(Index(t2.b)[[NULL,+inf]])->IndexReader(Index(t2.b_c)[[NULL,+inf]]->Sel([eq(test.t2.c, -1)]))}(test.t2.b,test.t1.b)->Projection", warning: "[planner:1815]Optimizer Hint /*+ TIDB_INLJ(t2) */ is inapplicable", }, } diff --git a/session/session_test.go b/session/session_test.go index bd44b6851ca13..1d260a16f922b 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -857,35 +857,35 @@ func (s *testSessionSuite) TestAutoIncrementID(c *C) { tk.MustQuery("select * from autoid").Check(testkit.Rows("1", "5000")) _, err = tk.Exec("update autoid set auto_inc_id = 8000") c.Assert(terror.ErrorEqual(err, kv.ErrKeyExists), IsTrue) - tk.MustQuery("select * from autoid").Check(testkit.Rows("1", "5000")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("1", "5000")) tk.MustExec("update autoid set auto_inc_id = 9000 where auto_inc_id=1") - tk.MustQuery("select * from autoid").Check(testkit.Rows("9000", "5000")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("9000", "5000")) tk.MustExec("insert into autoid values()") - tk.MustQuery("select * from autoid").Check(testkit.Rows("9000", "5000", "9001")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("9000", "5000", "9001")) // Corner cases for signed bigint auto_increment Columns. tk.MustExec("drop table if exists autoid") tk.MustExec("create table autoid(`auto_inc_id` bigint(20) NOT NULL AUTO_INCREMENT,UNIQUE KEY `auto_inc_id` (`auto_inc_id`))") tk.MustExec("insert into autoid values(9223372036854775806);") - tk.MustQuery("select auto_inc_id, _tidb_rowid from autoid").Check(testkit.Rows("9223372036854775806 9223372036854775807")) + tk.MustQuery("select auto_inc_id, _tidb_rowid from autoid use index()").Check(testkit.Rows("9223372036854775806 9223372036854775807")) _, err = tk.Exec("insert into autoid values();") c.Assert(terror.ErrorEqual(err, autoid.ErrAutoincReadFailed), IsTrue) - tk.MustQuery("select auto_inc_id, _tidb_rowid from autoid").Check(testkit.Rows("9223372036854775806 9223372036854775807")) + tk.MustQuery("select auto_inc_id, _tidb_rowid from autoid use index()").Check(testkit.Rows("9223372036854775806 9223372036854775807")) tk.MustQuery("select auto_inc_id, _tidb_rowid from autoid use index(auto_inc_id)").Check(testkit.Rows("9223372036854775806 9223372036854775807")) tk.MustExec("drop table if exists autoid") tk.MustExec("create table autoid(`auto_inc_id` bigint(20) NOT NULL AUTO_INCREMENT,UNIQUE KEY `auto_inc_id` (`auto_inc_id`))") tk.MustExec("insert into autoid values()") - tk.MustQuery("select * from autoid").Check(testkit.Rows("1")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("1")) tk.MustExec("insert into autoid values(5000)") - tk.MustQuery("select * from autoid").Check(testkit.Rows("1", "5000")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("1", "5000")) _, err = tk.Exec("update autoid set auto_inc_id = 8000") c.Assert(terror.ErrorEqual(err, kv.ErrKeyExists), IsTrue) - tk.MustQuery("select * from autoid").Check(testkit.Rows("1", "5000")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("1", "5000")) tk.MustExec("update autoid set auto_inc_id = 9000 where auto_inc_id=1") - tk.MustQuery("select * from autoid").Check(testkit.Rows("9000", "5000")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("9000", "5000")) tk.MustExec("insert into autoid values()") - tk.MustQuery("select * from autoid").Check(testkit.Rows("9000", "5000", "9001")) + tk.MustQuery("select * from autoid use index()").Check(testkit.Rows("9000", "5000", "9001")) } func (s *testSessionSuite) TestAutoIncrementWithRetry(c *C) { diff --git a/statistics/handle/update_test.go b/statistics/handle/update_test.go index 83705e8bf6908..fc91d29a84cee 100644 --- a/statistics/handle/update_test.go +++ b/statistics/handle/update_test.go @@ -1529,24 +1529,24 @@ func (s *testStatsSuite) TestFeedbackRanges(c *C) { }{ { sql: "select * from t where a <= 50 or (a > 130 and a < 140)", - hist: "column:1 ndv:30 totColSize:0\n" + - "num: 8 lower_bound: -128 upper_bound: 7 repeats: 0\n" + - "num: 8 lower_bound: 8 upper_bound: 15 repeats: 0\n" + - "num: 14 lower_bound: 16 upper_bound: 50 repeats: 0", + hist: "column:1 ndv:20 totColSize:0\n" + + "num: 8 lower_bound: 0 upper_bound: 7 repeats: 1\n" + + "num: 8 lower_bound: 8 upper_bound: 15 repeats: 1\n" + + "num: 4 lower_bound: 16 upper_bound: 19 repeats: 1", colID: 1, }, { sql: "select * from t where a >= 10", - hist: "column:1 ndv:30 totColSize:0\n" + - "num: 8 lower_bound: -128 upper_bound: 7 repeats: 0\n" + - "num: 8 lower_bound: 8 upper_bound: 15 repeats: 0\n" + - "num: 14 lower_bound: 16 upper_bound: 127 repeats: 0", + hist: "column:1 ndv:20 totColSize:0\n" + + "num: 8 lower_bound: 0 upper_bound: 7 repeats: 1\n" + + "num: 8 lower_bound: 8 upper_bound: 15 repeats: 1\n" + + "num: 4 lower_bound: 16 upper_bound: 19 repeats: 1", colID: 1, }, { sql: "select * from t use index(idx) where a = 1 and (b <= 50 or (b > 130 and b < 140))", hist: "column:2 ndv:20 totColSize:20\n" + - "num: 7 lower_bound: -128 upper_bound: 6 repeats: 0\n" + + "num: 9 lower_bound: -128 upper_bound: 6 repeats: 0\n" + "num: 7 lower_bound: 7 upper_bound: 13 repeats: 1\n" + "num: 6 lower_bound: 14 upper_bound: 19 repeats: 1", colID: 2, diff --git a/util/admin/admin.go b/util/admin/admin.go index 4a830342a5f85..a580edbb61bae 100644 --- a/util/admin/admin.go +++ b/util/admin/admin.go @@ -282,7 +282,7 @@ const ( // otherwise it returns an error and the corresponding index's offset. func CheckIndicesCount(ctx sessionctx.Context, dbName, tableName string, indices []string) (byte, int, error) { // Add `` for some names like `table name`. - sql := fmt.Sprintf("SELECT COUNT(*) FROM `%s`.`%s`", dbName, tableName) + sql := fmt.Sprintf("SELECT COUNT(*) FROM `%s`.`%s` USE INDEX()", dbName, tableName) tblCnt, err := getCount(ctx, sql) if err != nil { return 0, 0, errors.Trace(err)