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: tiny code refine for contructIndexJoin #12254

Merged
merged 6 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/explaintest/r/explain_complex.result
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ id count task operator info
Projection_10 0.00 root Column#1, Column#2, Column#4, Column#5, Column#3, Column#24, Column#25, Column#26, Column#11, Column#12, Column#13, Column#14, Column#15, Column#16, Column#17
└─Limit_13 0.00 root offset:0, count:2000
└─IndexMergeJoin_25 0.00 root inner join, inner:IndexLookUp_23, outer key:Column#2, Column#5, inner key:Column#21, Column#23
├─TableReader_53 0.00 root data:Selection_52
│ └─Selection_52 0.00 cop eq(Column#18, 0), eq(Column#4, "ios"), gt(Column#9, 1478185592), not(isnull(Column#5))
│ └─TableScan_51 10000.00 cop table:dt, range:[0,+inf], keep order:false, stats:pseudo
├─TableReader_40 0.00 root data:Selection_39
│ └─Selection_39 0.00 cop eq(Column#18, 0), eq(Column#4, "ios"), gt(Column#9, 1478185592), not(isnull(Column#5))
│ └─TableScan_38 10000.00 cop table:dt, range:[0,+inf], keep order:false, stats:pseudo
└─IndexLookUp_23 0.00 root
├─IndexScan_20 1.25 cop table:rr, index:aid, dic, range: decided by [eq(Column#21, Column#2) eq(Column#23, Column#5)], keep order:true, stats:pseudo
└─Selection_22 0.00 cop eq(Column#22, "ios"), gt(Column#26, 1478185592)
Expand Down
6 changes: 3 additions & 3 deletions cmd/explaintest/r/explain_complex_stats.result
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ id count task operator info
Projection_10 428.32 root Column#1, Column#2, Column#4, Column#5, Column#3, Column#24, Column#25, Column#26, Column#11, Column#12, Column#13, Column#14, Column#15, Column#16, Column#17
└─Limit_13 428.32 root offset:0, count:2000
└─IndexMergeJoin_25 428.32 root inner join, inner:IndexLookUp_23, outer key:Column#2, Column#5, inner key:Column#21, Column#23
├─TableReader_53 428.32 root data:Selection_52
│ └─Selection_52 428.32 cop eq(Column#18, 0), eq(Column#4, "ios"), gt(Column#9, 1478185592), not(isnull(Column#5))
│ └─TableScan_51 2000.00 cop table:dt, range:[0,+inf], keep order:false
├─TableReader_40 428.32 root data:Selection_39
│ └─Selection_39 428.32 cop eq(Column#18, 0), eq(Column#4, "ios"), gt(Column#9, 1478185592), not(isnull(Column#5))
│ └─TableScan_38 2000.00 cop table:dt, range:[0,+inf], keep order:false
└─IndexLookUp_23 0.48 root
├─IndexScan_20 1.00 cop table:rr, index:aid, dic, range: decided by [eq(Column#21, Column#2) eq(Column#23, Column#5)], keep order:true
└─Selection_22 0.48 cop eq(Column#22, "ios"), gt(Column#26, 1478185592)
Expand Down
14 changes: 7 additions & 7 deletions cmd/explaintest/r/explain_easy.result
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ Projection_11 5.00 root Column#12
├─TableReader_15 5.00 root data:TableScan_14
│ └─TableScan_14 5.00 cop table:t, range:[-inf,+inf], keep order:false
└─StreamAgg_20 1.00 root funcs:count(1)
└─MergeJoin_58 2.40 root inner join, left key:Column#4, right key:Column#7
├─IndexReader_45 2.40 root index:Selection_44
│ └─Selection_44 2.40 cop eq(3, Column#1)
│ └─IndexScan_43 3.00 cop table:s, index:b, range:[3,3], keep order:true
└─TableReader_48 4.00 root data:Selection_47
└─Selection_47 4.00 cop eq(3, Column#1)
└─TableScan_46 5.00 cop table:t1, range:[-inf,+inf], keep order:true
└─MergeJoin_49 2.40 root inner join, left key:Column#4, right key:Column#7
├─IndexReader_36 2.40 root index:Selection_35
│ └─Selection_35 2.40 cop eq(3, Column#1)
│ └─IndexScan_34 3.00 cop table:s, index:b, range:[3,3], keep order:true
└─TableReader_39 4.00 root data:Selection_38
└─Selection_38 4.00 cop eq(3, Column#1)
└─TableScan_37 5.00 cop table:t1, range:[-inf,+inf], keep order:true
explain select t.c in (select count(*) from t s left join t t1 on s.a = t1.a where 3 = t.a and s.b = 3) from t;
id count task operator info
Projection_10 5.00 root Column#12
Expand Down
14 changes: 7 additions & 7 deletions cmd/explaintest/r/generated_columns.result
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ IndexJoin_23 5.00 root inner join, inner:IndexLookUp_22, outer key:Column#8, inn
EXPLAIN SELECT * from sgc1 join sgc2 on sgc1.a=sgc2.a;
id count task operator info
Projection_6 5.00 root Column#1, Column#2, Column#3, Column#4, Column#6, Column#7, Column#8, Column#9
└─HashRightJoin_32 5.00 root inner join, inner:TableReader_51, equal:[eq(Column#8, Column#3)]
├─TableReader_51 1.00 root data:Selection_50
│ └─Selection_50 1.00 cop not(isnull(Column#8))
│ └─TableScan_49 1.00 cop table:sgc2, range:[-inf,+inf], keep order:false
└─TableReader_60 5.00 root data:Selection_59
└─Selection_59 5.00 cop not(isnull(Column#3))
└─TableScan_58 5.00 cop table:sgc1, range:[-inf,+inf], keep order:false
└─HashRightJoin_21 5.00 root inner join, inner:TableReader_40, equal:[eq(Column#8, Column#3)]
├─TableReader_40 1.00 root data:Selection_39
│ └─Selection_39 1.00 cop not(isnull(Column#8))
│ └─TableScan_38 1.00 cop table:sgc2, range:[-inf,+inf], keep order:false
└─TableReader_49 5.00 root data:Selection_48
└─Selection_48 5.00 cop not(isnull(Column#3))
└─TableScan_47 5.00 cop table:sgc1, range:[-inf,+inf], keep order:false
DROP TABLE IF EXISTS sgc3;
CREATE TABLE sgc3 (
j JSON,
Expand Down
14 changes: 7 additions & 7 deletions cmd/explaintest/r/index_join.result
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ IndexJoin_22 5.00 root inner join, inner:IndexLookUp_21, outer key:Column#4, inn
explain select * from t1 join t2 on t1.a=t2.a;
id count task operator info
Projection_6 5.00 root Column#1, Column#2, Column#4, Column#5
└─HashRightJoin_31 5.00 root inner join, inner:TableReader_42, equal:[eq(Column#4, Column#1)]
├─TableReader_42 1.00 root data:Selection_41
│ └─Selection_41 1.00 cop not(isnull(Column#4))
│ └─TableScan_40 1.00 cop table:t2, range:[-inf,+inf], keep order:false
└─TableReader_48 5.00 root data:Selection_47
└─Selection_47 5.00 cop not(isnull(Column#1))
└─TableScan_46 5.00 cop table:t1, range:[-inf,+inf], keep order:false
└─HashRightJoin_20 5.00 root inner join, inner:TableReader_31, equal:[eq(Column#4, Column#1)]
├─TableReader_31 1.00 root data:Selection_30
│ └─Selection_30 1.00 cop not(isnull(Column#4))
│ └─TableScan_29 1.00 cop table:t2, range:[-inf,+inf], keep order:false
└─TableReader_37 5.00 root data:Selection_36
└─Selection_36 5.00 cop not(isnull(Column#1))
└─TableScan_35 5.00 cop table:t1, range:[-inf,+inf], keep order:false
drop table if exists t1, t2;
create table t1(a int not null, b int not null);
create table t2(a int not null, b int not null, key a(a));
Expand Down
20 changes: 10 additions & 10 deletions cmd/explaintest/r/topn_push_down.result
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,21 @@ LIMIT 0, 5;
id count task operator info
Projection_13 0.00 root Column#47
└─Limit_19 0.00 root offset:0, count:5
└─IndexJoin_116 0.00 root left outer join, inner:IndexReader_115, outer key:Column#1, inner key:Column#97
├─TopN_123 0.00 root Column#47:asc, offset:0, count:5
└─IndexJoin_99 0.00 root left outer join, inner:IndexReader_98, outer key:Column#1, inner key:Column#97
├─TopN_106 0.00 root Column#47:asc, offset:0, count:5
│ └─IndexMergeJoin_47 0.00 root inner join, inner:IndexLookUp_45, outer key:Column#1, inner key:Column#41
│ ├─IndexLookUp_90 0.00 root
│ │ ├─Selection_88 0.00 cop eq(Column#4, 18), eq(Column#5, 1)
│ │ │ └─IndexScan_86 10.00 cop table:tr, index:shop_identy, trade_status, business_type, trade_pay_status, trade_type, delivery_type, source, biz_date, range:[810094178,810094178], keep order:false, stats:pseudo
│ │ └─Selection_89 0.00 cop eq(Column#21, 32314), eq(Column#3, 2)
│ │ └─TableScan_87 0.00 cop table:tr, keep order:false, stats:pseudo
│ ├─IndexLookUp_81 0.00 root
│ │ ├─Selection_79 0.00 cop eq(Column#4, 18), eq(Column#5, 1)
│ │ │ └─IndexScan_77 10.00 cop table:tr, index:shop_identy, trade_status, business_type, trade_pay_status, trade_type, delivery_type, source, biz_date, range:[810094178,810094178], keep order:false, stats:pseudo
│ │ └─Selection_80 0.00 cop eq(Column#21, 32314), eq(Column#3, 2)
│ │ └─TableScan_78 0.00 cop table:tr, keep order:false, stats:pseudo
│ └─IndexLookUp_45 0.03 root
│ ├─IndexScan_42 1.25 cop table:te, index:trade_id, range: decided by [eq(Column#41, Column#1)], keep order:true, stats:pseudo
│ └─Selection_44 0.03 cop ge(Column#47, 2018-04-23 00:00:00.000000), le(Column#47, 2018-04-23 23:59:59.000000)
│ └─TableScan_43 1.25 cop table:te, keep order:false, stats:pseudo
└─IndexReader_115 1.25 root index:Selection_114
└─Selection_114 1.25 cop not(isnull(Column#97))
└─IndexScan_113 1.25 cop table:p, index:relate_id, range: decided by [eq(Column#97, Column#1)], keep order:false, stats:pseudo
└─IndexReader_98 1.25 root index:Selection_97
└─Selection_97 1.25 cop not(isnull(Column#97))
└─IndexScan_96 1.25 cop table:p, index:relate_id, range: decided by [eq(Column#97, Column#1)], keep order:false, stats:pseudo
desc select 1 as a from dual order by a limit 1;
id count task operator info
Projection_6 1.00 root 1
Expand Down
38 changes: 19 additions & 19 deletions cmd/explaintest/r/tpch.result
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,12 @@ l_shipmode;
id count task operator info
Sort_9 1.00 root Column#29:asc
└─Projection_11 1.00 root Column#24, Column#27, Column#28
└─HashAgg_14 1.00 root group by:Column#36, funcs:sum(Column#0), sum(Column#0), firstrow(Column#0)
└─Projection_49 10023369.01 root cast(case(or(eq(Column#6, "1-URGENT"), eq(Column#6, "2-HIGH")), 1, 0)), cast(case(and(ne(Column#6, "1-URGENT"), ne(Column#6, "2-HIGH")), 1, 0)), Column#24, Column#24
└─HashAgg_14 1.00 root group by:Column#34, funcs:sum(Column#0), sum(Column#0), firstrow(Column#0)
└─Projection_38 10023369.01 root cast(case(or(eq(Column#6, "1-URGENT"), eq(Column#6, "2-HIGH")), 1, 0)), cast(case(and(ne(Column#6, "1-URGENT"), ne(Column#6, "2-HIGH")), 1, 0)), Column#24, Column#24
└─IndexMergeJoin_22 10023369.01 root inner join, inner:TableReader_20, outer key:Column#10, inner key:Column#1
├─TableReader_45 10023369.01 root data:Selection_44
│ └─Selection_44 10023369.01 cop ge(Column#22, 1997-01-01 00:00:00.000000), in(Column#24, "RAIL", "FOB"), lt(Column#20, Column#21), lt(Column#21, Column#22), lt(Column#22, 1998-01-01)
│ └─TableScan_43 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
├─TableReader_34 10023369.01 root data:Selection_33
│ └─Selection_33 10023369.01 cop ge(Column#22, 1997-01-01 00:00:00.000000), in(Column#24, "RAIL", "FOB"), lt(Column#20, Column#21), lt(Column#21, Column#22), lt(Column#22, 1998-01-01)
│ └─TableScan_32 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
└─TableReader_20 1.00 root data:TableScan_19
└─TableScan_19 1.00 cop table:orders, range: decided by [Column#10], keep order:true
/*
Expand Down Expand Up @@ -930,16 +930,16 @@ id count task operator info
Sort_13 3863988.24 root Column#28:desc, Column#25:asc, Column#26:asc, Column#27:asc
└─Projection_15 3863988.24 root Column#10, Column#11, Column#12, Column#24
└─HashAgg_18 3863988.24 root group by:Column#10, Column#11, Column#12, funcs:count(distinct Column#2), firstrow(Column#10), firstrow(Column#11), firstrow(Column#12)
└─HashLeftJoin_28 3863988.24 root anti semi join, inner:TableReader_62, equal:[eq(Column#2, Column#16)]
└─HashLeftJoin_28 3863988.24 root anti semi join, inner:TableReader_53, equal:[eq(Column#2, Column#16)]
├─IndexMergeJoin_36 4829985.30 root inner join, inner:IndexReader_34, outer key:Column#7, inner key:Column#1
│ ├─TableReader_55 1200618.43 root data:Selection_54
│ │ └─Selection_54 1200618.43 cop in(Column#12, 48, 19, 12, 4, 41, 7, 21, 39), ne(Column#10, "Brand#34"), not(like(Column#11, "LARGE BRUSHED%", 92))
│ │ └─TableScan_53 10000000.00 cop table:part, range:[-inf,+inf], keep order:false
│ ├─TableReader_46 1200618.43 root data:Selection_45
│ │ └─Selection_45 1200618.43 cop in(Column#12, 48, 19, 12, 4, 41, 7, 21, 39), ne(Column#10, "Brand#34"), not(like(Column#11, "LARGE BRUSHED%", 92))
│ │ └─TableScan_44 10000000.00 cop table:part, range:[-inf,+inf], keep order:false
│ └─IndexReader_34 4.02 root index:IndexScan_33
│ └─IndexScan_33 4.02 cop table:partsupp, index:PS_PARTKEY, PS_SUPPKEY, range: decided by [eq(Column#1, Column#7)], keep order:true
└─TableReader_62 400000.00 root data:Selection_61
└─Selection_61 400000.00 cop like(Column#22, "%Customer%Complaints%", 92)
└─TableScan_60 500000.00 cop table:supplier, range:[-inf,+inf], keep order:false
└─TableReader_53 400000.00 root data:Selection_52
└─Selection_52 400000.00 cop like(Column#22, "%Customer%Complaints%", 92)
└─TableScan_51 500000.00 cop table:supplier, range:[-inf,+inf], keep order:false
/*
Q17 Small-Quantity-Order Revenue Query
This query determines how much average yearly revenue would be lost if orders were no longer filled for small
Expand Down Expand Up @@ -1158,17 +1158,17 @@ Sort_28 20000.00 root Column#48:asc
└─Projection_52 64006.34 root Column#12, Column#13, Column#14, Column#18, mul(0.5, Column#45)
└─Selection_53 64006.34 root gt(cast(Column#14), mul(0.5, Column#45))
└─HashAgg_56 80007.93 root group by:Column#12, Column#13, funcs:firstrow(Column#12), firstrow(Column#13), firstrow(Column#14), firstrow(Column#18), sum(Column#32)
└─HashLeftJoin_59 9711455.06 root left outer join, inner:TableReader_95, equal:[eq(Column#12, Column#29) eq(Column#13, Column#30)]
└─HashLeftJoin_59 9711455.06 root left outer join, inner:TableReader_86, equal:[eq(Column#12, Column#29) eq(Column#13, Column#30)]
├─IndexMergeJoin_69 321865.05 root inner join, inner:IndexLookUp_67, outer key:Column#18, inner key:Column#12
│ ├─TableReader_90 80007.93 root data:Selection_89
│ │ └─Selection_89 80007.93 cop like(Column#19, "green%", 92)
│ │ └─TableScan_88 10000000.00 cop table:part, range:[-inf,+inf], keep order:false
│ ├─TableReader_81 80007.93 root data:Selection_80
│ │ └─Selection_80 80007.93 cop like(Column#19, "green%", 92)
│ │ └─TableScan_79 10000000.00 cop table:part, range:[-inf,+inf], keep order:false
│ └─IndexLookUp_67 4.02 root
│ ├─IndexScan_65 4.02 cop table:partsupp, index:PS_PARTKEY, PS_SUPPKEY, range: decided by [eq(Column#12, Column#18)], keep order:true
│ └─TableScan_66 4.02 cop table:partsupp, keep order:false
└─TableReader_95 44189356.65 root data:Selection_94
└─Selection_94 44189356.65 cop ge(Column#38, 1993-01-01 00:00:00.000000), lt(Column#38, 1994-01-01)
└─TableScan_93 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
└─TableReader_86 44189356.65 root data:Selection_85
└─Selection_85 44189356.65 cop ge(Column#38, 1993-01-01 00:00:00.000000), lt(Column#38, 1994-01-01)
└─TableScan_84 300005811.00 cop table:lineitem, range:[-inf,+inf], keep order:false
/*
Q21 Suppliers Who Kept Orders Waiting Query
This query identifies certain suppliers who were not able to ship required parts in a timely manner.
Expand Down
Loading