Skip to content

Commit

Permalink
Merge branch 'encode_key' of https://github.com/crazycs520/tidb into …
Browse files Browse the repository at this point in the history
…encode_key
  • Loading branch information
crazycs520 committed Sep 17, 2019
2 parents c6069ff + cae01dc commit bc55f0e
Show file tree
Hide file tree
Showing 53 changed files with 2,344 additions and 2,055 deletions.
58 changes: 29 additions & 29 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,39 +328,39 @@ func (s *testSuite) TestGlobalAndSessionBindingBothExist(c *C) {
tk.MustExec("create table t2(id int)")

tk.MustQuery("explain SELECT * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"HashLeftJoin_8 12487.50 root inner join, inner:TableReader_15, equal:[eq(test.t1.id, test.t2.id)]",
"HashLeftJoin_8 12487.50 root inner join, inner:TableReader_15, equal:[eq(Column#1, Column#3)]",
"├─TableReader_12 9990.00 root data:Selection_11",
"│ └─Selection_11 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_11 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_10 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─TableReader_15 9990.00 root data:Selection_14",
" └─Selection_14 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_14 9990.00 cop not(isnull(Column#3))",
" └─TableScan_13 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))

tk.MustQuery("explain SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"MergeJoin_7 12487.50 root inner join, left key:test.t1.id, right key:test.t2.id",
"├─Sort_11 9990.00 root test.t1.id:asc",
"MergeJoin_7 12487.50 root inner join, left key:Column#1, right key:Column#3",
"├─Sort_11 9990.00 root Column#1:asc",
"│ └─TableReader_10 9990.00 root data:Selection_9",
"│ └─Selection_9 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_9 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_8 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─Sort_15 9990.00 root test.t2.id:asc",
"└─Sort_15 9990.00 root Column#3:asc",
" └─TableReader_14 9990.00 root data:Selection_13",
" └─Selection_13 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_13 9990.00 cop not(isnull(Column#3))",
" └─TableScan_12 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))

tk.MustExec("create global binding for SELECT * from t1,t2 where t1.id = t2.id using SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id")

metrics.BindUsageCounter.Reset()
tk.MustQuery("explain SELECT * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"MergeJoin_7 12487.50 root inner join, left key:test.t1.id, right key:test.t2.id",
"├─Sort_11 9990.00 root test.t1.id:asc",
"MergeJoin_7 12487.50 root inner join, left key:Column#1, right key:Column#3",
"├─Sort_11 9990.00 root Column#1:asc",
"│ └─TableReader_10 9990.00 root data:Selection_9",
"│ └─Selection_9 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_9 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_8 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─Sort_15 9990.00 root test.t2.id:asc",
"└─Sort_15 9990.00 root Column#3:asc",
" └─TableReader_14 9990.00 root data:Selection_13",
" └─Selection_13 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_13 9990.00 cop not(isnull(Column#3))",
" └─TableScan_12 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))
pb := &dto.Metric{}
Expand All @@ -370,12 +370,12 @@ func (s *testSuite) TestGlobalAndSessionBindingBothExist(c *C) {
tk.MustExec("drop global binding for SELECT * from t1,t2 where t1.id = t2.id")

tk.MustQuery("explain SELECT * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"HashLeftJoin_8 12487.50 root inner join, inner:TableReader_15, equal:[eq(test.t1.id, test.t2.id)]",
"HashLeftJoin_8 12487.50 root inner join, inner:TableReader_15, equal:[eq(Column#1, Column#3)]",
"├─TableReader_12 9990.00 root data:Selection_11",
"│ └─Selection_11 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_11 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_10 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─TableReader_15 9990.00 root data:Selection_14",
" └─Selection_14 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_14 9990.00 cop not(isnull(Column#3))",
" └─TableScan_13 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))
}
Expand All @@ -390,38 +390,38 @@ func (s *testSuite) TestExplain(c *C) {
tk.MustExec("create table t2(id int)")

tk.MustQuery("explain SELECT * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"HashLeftJoin_8 12487.50 root inner join, inner:TableReader_15, equal:[eq(test.t1.id, test.t2.id)]",
"HashLeftJoin_8 12487.50 root inner join, inner:TableReader_15, equal:[eq(Column#1, Column#3)]",
"├─TableReader_12 9990.00 root data:Selection_11",
"│ └─Selection_11 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_11 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_10 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─TableReader_15 9990.00 root data:Selection_14",
" └─Selection_14 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_14 9990.00 cop not(isnull(Column#3))",
" └─TableScan_13 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))

tk.MustQuery("explain SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"MergeJoin_7 12487.50 root inner join, left key:test.t1.id, right key:test.t2.id",
"├─Sort_11 9990.00 root test.t1.id:asc",
"MergeJoin_7 12487.50 root inner join, left key:Column#1, right key:Column#3",
"├─Sort_11 9990.00 root Column#1:asc",
"│ └─TableReader_10 9990.00 root data:Selection_9",
"│ └─Selection_9 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_9 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_8 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─Sort_15 9990.00 root test.t2.id:asc",
"└─Sort_15 9990.00 root Column#3:asc",
" └─TableReader_14 9990.00 root data:Selection_13",
" └─Selection_13 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_13 9990.00 cop not(isnull(Column#3))",
" └─TableScan_12 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))

tk.MustExec("create global binding for SELECT * from t1,t2 where t1.id = t2.id using SELECT /*+ TIDB_SMJ(t1, t2) */ * from t1,t2 where t1.id = t2.id")

tk.MustQuery("explain SELECT * from t1,t2 where t1.id = t2.id").Check(testkit.Rows(
"MergeJoin_7 12487.50 root inner join, left key:test.t1.id, right key:test.t2.id",
"├─Sort_11 9990.00 root test.t1.id:asc",
"MergeJoin_7 12487.50 root inner join, left key:Column#1, right key:Column#3",
"├─Sort_11 9990.00 root Column#1:asc",
"│ └─TableReader_10 9990.00 root data:Selection_9",
"│ └─Selection_9 9990.00 cop not(isnull(test.t1.id))",
"│ └─Selection_9 9990.00 cop not(isnull(Column#1))",
"│ └─TableScan_8 10000.00 cop table:t1, range:[-inf,+inf], keep order:false, stats:pseudo",
"└─Sort_15 9990.00 root test.t2.id:asc",
"└─Sort_15 9990.00 root Column#3:asc",
" └─TableReader_14 9990.00 root data:Selection_13",
" └─Selection_13 9990.00 cop not(isnull(test.t2.id))",
" └─Selection_13 9990.00 cop not(isnull(Column#3))",
" └─TableScan_12 10000.00 cop table:t2, range:[-inf,+inf], keep order:false, stats:pseudo",
))

Expand Down
12 changes: 6 additions & 6 deletions cmd/explaintest/r/access_path_selection.result
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ IndexReader_6 3323.33 root index:IndexScan_5
explain select a, b from access_path_selection where b < 3;
id count task operator info
IndexReader_13 3323.33 root index:Selection_12
└─Selection_12 3323.33 cop lt(test.access_path_selection.b, 3)
└─Selection_12 3323.33 cop lt(Column#2, 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
└─Selection_10 1104.45 cop lt(test.access_path_selection.b, 3)
└─Selection_10 1104.45 cop lt(Column#2, 3)
└─IndexScan_9 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 a > 10 order by _tidb_rowid;
id count task operator info
Projection_6 3333.33 root test.access_path_selection.a, test.access_path_selection.b
Projection_6 3333.33 root Column#1, Column#2
└─TableReader_13 3333.33 root data:Selection_12
└─Selection_12 3333.33 cop gt(test.access_path_selection.a, 10)
└─Selection_12 3333.33 cop gt(Column#1, 10)
└─TableScan_11 10000.00 cop table:access_path_selection, range:[-inf,+inf], keep order:true, stats:pseudo
explain select max(_tidb_rowid) from access_path_selection;
id count task operator info
StreamAgg_13 1.00 root funcs:max(test.access_path_selection._tidb_rowid)
StreamAgg_13 1.00 root funcs:max(Column#3)
└─Limit_17 1.00 root offset:0, count:1
└─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)
StreamAgg_28 1.00 root funcs:count(Column#7)
└─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
14 changes: 7 additions & 7 deletions cmd/explaintest/r/black_list.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ create table t (a int);
explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.t.a, 1)
└─Selection_6 3323.33 cop lt(Column#1, 1)
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
insert into mysql.opt_rule_blacklist values('predicate_push_down');
admin reload opt_rule_blacklist;

explain select * from t where a < 1;
id count task operator info
Selection_5 8000.00 root lt(test.t.a, 1)
Selection_5 8000.00 root lt(Column#1, 1)
└─TableReader_7 10000.00 root data:TableScan_6
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
delete from mysql.opt_rule_blacklist where name='predicate_push_down';
Expand All @@ -20,14 +20,14 @@ admin reload opt_rule_blacklist;
explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.t.a, 1)
└─Selection_6 3323.33 cop lt(Column#1, 1)
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
insert into mysql.expr_pushdown_blacklist values('<');
admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;
id count task operator info
Selection_5 8000.00 root lt(test.t.a, 1)
Selection_5 8000.00 root lt(Column#1, 1)
└─TableReader_7 10000.00 root data:TableScan_6
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
delete from mysql.expr_pushdown_blacklist where name='<';
Expand All @@ -36,14 +36,14 @@ admin reload expr_pushdown_blacklist;
explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.t.a, 1)
└─Selection_6 3323.33 cop lt(Column#1, 1)
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
insert into mysql.expr_pushdown_blacklist values('lt');
admin reload expr_pushdown_blacklist;

explain select * from t where a < 1;
id count task operator info
Selection_5 8000.00 root lt(test.t.a, 1)
Selection_5 8000.00 root lt(Column#1, 1)
└─TableReader_7 10000.00 root data:TableScan_6
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
delete from mysql.expr_pushdown_blacklist where name='lt';
Expand All @@ -52,5 +52,5 @@ admin reload expr_pushdown_blacklist;
explain select * from t where a < 1;
id count task operator info
TableReader_7 3323.33 root data:Selection_6
└─Selection_6 3323.33 cop lt(test.t.a, 1)
└─Selection_6 3323.33 cop lt(Column#1, 1)
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo
8 changes: 4 additions & 4 deletions cmd/explaintest/r/explain.result
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ set session tidb_hashagg_partial_concurrency = 1;
set session tidb_hashagg_final_concurrency = 1;
explain select group_concat(a) from t group by id;
id count task operator info
StreamAgg_8 8000.00 root group by:col_1, funcs:group_concat(col_0, ",")
└─Projection_18 10000.00 root cast(test.t.a), test.t.id
StreamAgg_8 8000.00 root group by:Column#6, funcs:group_concat(Column#0, ",")
└─Projection_18 10000.00 root cast(Column#2), Column#1
└─TableReader_15 10000.00 root data:TableScan_14
└─TableScan_14 10000.00 cop table:t, range:[-inf,+inf], keep order:true, stats:pseudo
explain select group_concat(a, b) from t group by id;
id count task operator info
StreamAgg_8 8000.00 root group by:col_2, funcs:group_concat(col_0, col_1, ",")
└─Projection_18 10000.00 root cast(test.t.a), cast(test.t.b), test.t.id
StreamAgg_8 8000.00 root group by:Column#6, funcs:group_concat(Column#0, Column#0, ",")
└─Projection_18 10000.00 root cast(Column#2), cast(Column#3), Column#1
└─TableReader_15 10000.00 root data:TableScan_14
└─TableScan_14 10000.00 cop table:t, range:[-inf,+inf], keep order:true, stats:pseudo
drop table t;
Loading

0 comments on commit bc55f0e

Please sign in to comment.