Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pingcap/tidb into group-by
Browse files Browse the repository at this point in the history
  • Loading branch information
alivxxx committed Sep 24, 2019
2 parents 8fce9af + 8179558 commit 7018982
Show file tree
Hide file tree
Showing 86 changed files with 2,022 additions and 499 deletions.
4 changes: 2 additions & 2 deletions cmd/ddltest/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func (s *TestDDLSuite) checkAddIndex(c *C, indexInfo *model.IndexInfo) {
}

func (s *TestDDLSuite) checkDropIndex(c *C, indexInfo *model.IndexInfo) {
gc_worker, err := gcworker.NewMockGCWorker(s.store.(tikv.Storage))
gcWorker, err := gcworker.NewMockGCWorker(s.store.(tikv.Storage))
c.Assert(err, IsNil)
err = gc_worker.DeleteRanges(goctx.Background(), uint64(math.MaxInt32))
err = gcWorker.DeleteRanges(goctx.Background(), uint64(math.MaxInt32))
c.Assert(err, IsNil)

ctx := s.ctx
Expand Down
29 changes: 29 additions & 0 deletions cmd/explaintest/r/explain-non-select-stmt.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use test;
drop table if exists t;
create table t(a bigint, b bigint);
explain insert into t values(1, 1);
id count task operator info
Insert_1 N/A root N/A
explain insert into t select * from t;
id count task operator info
Insert_1 N/A root N/A
└─TableReader_7 10000.00 root data:TableScan_6
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain delete from t where a > 100;
id count task operator info
Delete_3 N/A root N/A
└─TableReader_6 3333.33 root data:Selection_5
└─Selection_5 3333.33 cop gt(Column#1, 100)
└─TableScan_4 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain update t set b = 100 where a = 200;
id count task operator info
Update_3 N/A root N/A
└─TableReader_6 10.00 root data:Selection_5
└─Selection_5 10.00 cop eq(Column#1, 200)
└─TableScan_4 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain replace into t select a, 100 from t;
id count task operator info
Insert_1 N/A root N/A
└─Projection_5 10000.00 root Column#3, 100
└─TableReader_7 10000.00 root data:TableScan_6
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
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
40 changes: 21 additions & 19 deletions cmd/explaintest/r/explain_easy.result
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ HashLeftJoin_19 4166.67 root left outer join, inner:TableReader_32, equal:[eq(Co
└─TableScan_30 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo
explain update t1 set t1.c2 = 2 where t1.c1 = 1;
id count task operator info
Point_Get_1 1.00 root table:t1, handle:1
Update_2 N/A root N/A
└─Point_Get_1 1.00 root table:t1, handle:1
explain delete from t1 where t1.c2 = 1;
id count task operator info
IndexLookUp_9 10.00 root
├─IndexScan_7 10.00 cop table:t1, index:c2, range:[1,1], keep order:false, stats:pseudo
└─TableScan_8 10.00 cop table:t1, keep order:false, stats:pseudo
Delete_3 N/A root N/A
└─IndexLookUp_9 10.00 root
├─IndexScan_7 10.00 cop table:t1, index:c2, range:[1,1], keep order:false, stats:pseudo
└─TableScan_8 10.00 cop table:t1, keep order:false, stats:pseudo
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 9990.00 root cast(Column#9)
Expand Down Expand Up @@ -120,15 +122,14 @@ 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 10000.00 root eq(Column#2, Column#5)
└─Apply_14 10000.00 root CARTESIAN left outer join, inner:Limit_23
└─Apply_14 10000.00 root CARTESIAN left outer join, inner:Projection_43
├─IndexReader_18 10000.00 root index:IndexScan_17
│ └─IndexScan_17 10000.00 cop table:t1, index:c2, range:[NULL,+inf], keep order:false, stats:pseudo
└─Limit_23 1.00 root offset:0, count:1
└─Projection_43 1.00 root Column#4, Column#5
└─IndexLookUp_42 1.00 root
├─Limit_41 1.00 cop offset:0, count:1
│ └─IndexScan_39 1.00 cop table:t2, index:c1, range: decided by [eq(Column#1, Column#4)], keep order:true, stats:pseudo
└─TableScan_40 1.00 cop table:t2, keep order:false, stats:pseudo
└─Projection_43 1.00 root Column#4, Column#5
└─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1)
├─Limit_41 1.00 cop offset:0, count:1
│ └─IndexScan_39 1.00 cop table:t2, index:c1, range: decided by [eq(Column#1, Column#4)], keep order:true, stats:pseudo
└─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 Down Expand Up @@ -349,13 +350,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 Expand Up @@ -658,7 +659,8 @@ begin;
insert into t values (1, 1);
explain update t set j = -j where i = 1 and j = 1;
id count task operator info
Point_Get_1 1.00 root table:t, index:i j
Update_2 N/A root N/A
└─Point_Get_1 1.00 root table:t, index:i j
rollback;
drop table if exists t;
create table t(a int);
Expand Down
41 changes: 20 additions & 21 deletions cmd/explaintest/r/explain_easy_stats.result
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ HashLeftJoin_19 2481.25 root left outer join, inner:TableReader_32, equal:[eq(Co
└─TableScan_30 1985.00 cop table:t2, range:[-inf,+inf], keep order:false
explain update t1 set t1.c2 = 2 where t1.c1 = 1;
id count task operator info
Point_Get_1 1.00 root table:t1, handle:1
Update_2 N/A root N/A
└─Point_Get_1 1.00 root table:t1, handle:1
explain delete from t1 where t1.c2 = 1;
id count task operator info
IndexLookUp_9 0.00 root
├─IndexScan_7 0.00 cop table:t1, index:c2, range:[1,1], keep order:false
└─TableScan_8 0.00 cop table:t1, keep order:false
Delete_3 N/A root N/A
└─IndexLookUp_9 0.00 root
├─IndexScan_7 0.00 cop table:t1, index:c2, range:[1,1], keep order:false
└─TableScan_8 0.00 cop table:t1, keep order:false
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(Column#9)
Expand Down Expand Up @@ -104,15 +106,14 @@ 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(Column#2, Column#5)
└─Apply_14 1999.00 root CARTESIAN left outer join, inner:Limit_23
└─Apply_14 1999.00 root CARTESIAN left outer join, inner:Projection_43
├─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 Column#4, Column#5
└─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(Column#1, Column#4)], keep order:true
└─TableScan_40 1.00 cop table:t2, keep order:false, stats:pseudo
└─Projection_43 1.00 root Column#4, Column#5
└─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1)
├─Limit_41 1.00 cop offset:0, count:1
│ └─IndexScan_39 1.25 cop table:t2, index:c1, range: decided by [eq(Column#1, Column#4)], 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 Down Expand Up @@ -165,18 +166,16 @@ id count task operator info
TableDual_5 0.00 root rows:0
explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 1, 1;
id count task operator info
Limit_9 1.00 root offset:1, count:1
└─IndexLookUp_14 1.00 root
├─Limit_13 1.00 cop offset:0, count:2
│ └─IndexScan_11 1.00 cop table:index_prune, index:a, b, range:[1010010404050976781 26467085526790,1010010404050976781 26467085526790], keep order:false
└─TableScan_12 1.00 cop table:index_prune, keep order:false, stats:pseudo
IndexLookUp_14 1.00 root limit embedded(offset:1, count:1)
├─Limit_13 1.00 cop offset:0, count:2
│ └─IndexScan_11 1.00 cop table:index_prune, index:a, b, range:[1010010404050976781 26467085526790,1010010404050976781 26467085526790], keep order:false
└─TableScan_12 1.00 cop table:index_prune, keep order:false, stats:pseudo
explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 1, 0;
id count task operator info
Limit_9 0.00 root offset:1, count:0
└─IndexLookUp_14 1.00 root
├─Limit_13 1.00 cop offset:0, count:1
│ └─IndexScan_11 1.00 cop table:index_prune, index:a, b, range:[1010010404050976781 26467085526790,1010010404050976781 26467085526790], keep order:false
└─TableScan_12 1.00 cop table:index_prune, keep order:false, stats:pseudo
IndexLookUp_14 0.00 root limit embedded(offset:1, count:0)
├─Limit_13 1.00 cop offset:0, count:1
│ └─IndexScan_11 1.00 cop table:index_prune, index:a, b, range:[1010010404050976781 26467085526790,1010010404050976781 26467085526790], keep order:false
└─TableScan_12 0.00 cop table:index_prune, keep order:false, stats:pseudo
explain select * from index_prune WHERE a = 1010010404050976781 AND b = 26467085526790 LIMIT 0, 1;
id count task operator info
Point_Get_1 1.00 root table:index_prune, index:a b
Expand Down
33 changes: 33 additions & 0 deletions cmd/explaintest/r/explain_indexmerge.result
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,36 @@ IndexMerge_17 0.00 root
├─IndexScan_14 9.00 cop table:t, index:d, range:[-inf,10), keep order:false
└─Selection_16 0.00 cop lt(Column#6, 10), or(lt(Column#2, 10000), lt(Column#3, 10000))
└─TableScan_15 18.00 cop table:t, keep order:false
explain format="dot" select * from t where (a < 50 or b < 50) and f > 100;
dot contents

digraph IndexMerge_12 {
subgraph cluster12{
node [style=filled, color=lightgrey]
color=black
label = "root"
"IndexMerge_12"
}
subgraph cluster8{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"TableScan_8"
}
subgraph cluster9{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"IndexScan_9"
}
subgraph cluster11{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"Selection_11" -> "TableScan_10"
}
"IndexMerge_12" -> "TableScan_8"
"IndexMerge_12" -> "IndexScan_9"
"IndexMerge_12" -> "Selection_11"
}

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
Loading

0 comments on commit 7018982

Please sign in to comment.