Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: generate index path as candidate when it is a single scan #12022

Merged
merged 19 commits into from Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions cmd/explaintest/r/access_path_selection.result
Expand Up @@ -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
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.access_path_selection.b, 3)
└─TableScan_5 10000.00 cop table:access_path_selection, range:[-inf,+inf], keep order:false, stats:pseudo
IndexReader_13 3323.33 root index:Selection_12
└─Selection_12 3323.33 cop lt(test.access_path_selection.b, 3)
└─IndexScan_11 10000.00 cop table:access_path_selection, index:a, b, range:[NULL,+inf], 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
Expand All @@ -36,3 +36,9 @@ StreamAgg_13 1.00 root funcs:max(test.access_path_selection._tidb_rowid)
└─TableReader_27 1.00 root data:Limit_26
└─Limit_26 1.00 cop offset:0, count:1
└─TableScan_25 1.25 cop table:access_path_selection, range:[-inf,+inf], keep order:true, desc, stats:pseudo
explain select count(1) from access_path_selection;
id count task operator info
StreamAgg_28 1.00 root funcs:count(col_0)
└─IndexReader_29 1.00 root index:StreamAgg_8
└─StreamAgg_8 1.00 cop funcs:count(1)
└─IndexScan_25 10000.00 cop table:access_path_selection, index:a, range:[NULL,+inf], keep order:false, stats:pseudo
218 changes: 109 additions & 109 deletions cmd/explaintest/r/explain_easy.result

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions cmd/explaintest/r/explain_easy_stats.result
Expand Up @@ -65,8 +65,8 @@ explain select count(b.c2) from t1 a, t2 b where a.c1 = b.c2 group by a.c1;
id count task operator info
Projection_11 1985.00 root cast(join_agg_0)
└─HashLeftJoin_19 1985.00 root inner join, inner:HashAgg_23, equal:[eq(test.a.c1, test.b.c2)]
├─TableReader_32 1999.00 root data:TableScan_31
│ └─TableScan_31 1999.00 cop table:a, range:[-inf,+inf], keep order:false
├─IndexReader_34 1999.00 root index:IndexScan_33
│ └─IndexScan_33 1999.00 cop table:a, index:c2, range:[NULL,+inf], keep order:false
└─HashAgg_23 1985.00 root group by:test.b.c2, funcs:count(test.b.c2), firstrow(test.b.c2)
└─TableReader_30 1985.00 root data:Selection_29
└─Selection_29 1985.00 cop not(isnull(test.b.c2))
Expand All @@ -92,8 +92,8 @@ explain select c1 from t1 where c1 in (select c2 from t2);
id count task operator info
Projection_9 1985.00 root test.t1.c1
└─HashLeftJoin_17 1985.00 root inner join, inner:HashAgg_21, equal:[eq(test.t1.c1, test.t2.c2)]
├─TableReader_30 1999.00 root data:TableScan_29
│ └─TableScan_29 1999.00 cop table:t1, range:[-inf,+inf], keep order:false
├─IndexReader_32 1999.00 root index:IndexScan_31
│ └─IndexScan_31 1999.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false
└─HashAgg_21 1985.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)
└─TableReader_28 1985.00 root data:Selection_27
└─Selection_27 1985.00 cop not(isnull(test.t2.c2))
Expand All @@ -104,15 +104,15 @@ MemTableScan_4 10000.00 root
explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) from t1;
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
└─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
├─Limit_39 1.00 cop offset:0, count:1
│ └─IndexScan_37 1.25 cop table:t2, index:c1, range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true
└─TableScan_38 1.00 cop table:t2, keep order:false, stats:pseudo
└─Apply_14 1999.00 root CARTESIAN left outer join, inner:Limit_23
├─IndexReader_18 1999.00 root index:IndexScan_17
│ └─IndexScan_17 1999.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false
└─Limit_23 1.00 root offset:0, count:1
└─Projection_43 1.00 root test.t2.c1, test.t2.c2
└─IndexLookUp_42 1.00 root
├─Limit_41 1.00 cop offset:0, count:1
│ └─IndexScan_39 1.25 cop table:t2, index:c1, range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true
└─TableScan_40 1.00 cop table:t2, keep order:false, stats:pseudo
explain select * from t1 order by c1 desc limit 1;
id count task operator info
Limit_10 1.00 root offset:0, count:1
Expand All @@ -123,12 +123,12 @@ set @@session.tidb_opt_insubq_to_join_and_agg=0;
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
└─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
└─HashLeftJoin_7 1999.00 root CARTESIAN left outer semi join, inner:TableReader_14
├─IndexReader_11 1999.00 root index:IndexScan_10
│ └─IndexScan_10 1999.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false
└─TableReader_14 0.00 root data:Selection_13
└─Selection_13 0.00 cop eq(1, test.t2.c2)
└─TableScan_12 1985.00 cop table:t2, range:[-inf,+inf], keep order:false
explain format="dot" select 1 in (select c2 from t2) from t1;
dot contents

Expand All @@ -138,23 +138,23 @@ node [style=filled, color=lightgrey]
color=black
label = "root"
"Projection_6" -> "HashLeftJoin_7"
"HashLeftJoin_7" -> "TableReader_9"
"HashLeftJoin_7" -> "TableReader_12"
"HashLeftJoin_7" -> "IndexReader_11"
"HashLeftJoin_7" -> "TableReader_14"
}
subgraph cluster8{
subgraph cluster10{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"TableScan_8"
"IndexScan_10"
}
subgraph cluster11{
subgraph cluster13{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"Selection_11" -> "TableScan_10"
"Selection_13" -> "TableScan_12"
}
"TableReader_9" -> "TableScan_8"
"TableReader_12" -> "Selection_11"
"IndexReader_11" -> "IndexScan_10"
"TableReader_14" -> "Selection_13"
}

explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 1;
Expand Down
6 changes: 3 additions & 3 deletions cmd/explaintest/r/generated_columns.result
Expand Up @@ -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
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.sgc.b, 3)
└─TableScan_5 10000.00 cop table:sgc, range:[-inf,+inf], keep order:false, stats:pseudo
IndexReader_13 3323.33 root index:Selection_12
└─Selection_12 3323.33 cop lt(test.sgc.b, 3)
└─IndexScan_11 10000.00 cop table:sgc, index:a, b, range:[NULL,+inf], 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
Expand Down
4 changes: 2 additions & 2 deletions cmd/explaintest/r/index_join.result
Expand Up @@ -51,5 +51,5 @@ Projection_8 10000.00 root test.t1.a, test.t1.b
│ ├─IndexScan_9 10.00 cop table:t1, index:a, range: decided by [eq(test.t1.a, test.t2.a)], keep order:false, stats:pseudo
│ └─TableScan_10 10.00 cop table:t1, keep order:false, stats:pseudo
└─StreamAgg_22 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)
└─IndexReader_32 10000.00 root index:IndexScan_31
└─IndexScan_31 10000.00 cop table:t2, index:a, range:[NULL,+inf], keep order:true, stats:pseudo
└─IndexReader_35 10000.00 root index:IndexScan_34
└─IndexScan_34 10000.00 cop table:t2, index:a, range:[NULL,+inf], keep order:true, stats:pseudo