forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplain_easy.test
102 lines (90 loc) · 4.35 KB
/
explain_easy.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use test;
drop table if exists t1, t2, t3, t4;
create table t1 (c1 int primary key, c2 int, c3 int, index c2 (c2));
create table t2 (c1 int unique, c2 int);
insert into t2 values(1, 0), (2, 1);
create table t3 (a bigint, b bigint, c bigint, d bigint);
create table t4 (a int, b int, c int, index idx(a, b), primary key(a));
set @@session.tidb_opt_insubquery_unfold = 1;
set @@session.tidb_opt_agg_push_down = 1;
explain select * from t3 where exists (select s.a from t3 s having sum(s.a) = t3.a );
explain select * from t1;
explain select * from t1 order by c2;
explain select * from t2 order by c2;
explain select * from t1 where t1.c1 > 0;
explain select t1.c1, t1.c2 from t1 where t1.c2 = 1;
explain select * from t1 left join t2 on t1.c2 = t2.c1 where t1.c1 > 1;
explain update t1 set t1.c2 = 2 where t1.c1 = 1;
explain delete from t1 where t1.c2 = 1;
explain select count(b.c2) from t1 a, t2 b where a.c1 = b.c2 group by a.c1;
explain select * from t2 order by t2.c2 limit 0, 1;
explain select * from t1 where c1 > 1 and c2 = 1 and c3 < 1;
explain select * from t1 where c1 = 1 and c2 > 1;
explain select sum(t1.c1 in (select c1 from t2)) from t1;
explain select c1 from t1 where c1 in (select c2 from t2);
explain select (select count(1) k from t1 s where s.c1 = t1.c1 having k != 0) from t1;
explain select * from information_schema.columns;
explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) from t1;
explain select * from t1 order by c1 desc limit 1;
explain select * from t4 use index(idx) where a > 1 and b > 1 and c > 1 limit 1;
explain select * from t4 where a > 1 and c > 1 limit 1;
explain select ifnull(null, t1.c1) from t1;
explain select if(10, t1.c1, t1.c2) from t1;
explain select c1 from t2 union select c1 from t2 union all select c1 from t2;
explain select c1 from t2 union all select c1 from t2 union select c1 from t2;
set @@session.tidb_opt_insubquery_unfold = 0;
explain select sum(t1.c1 in (select c1 from t2)) from t1;
explain select 1 in (select c2 from t2) from t1;
explain select sum(6 in (select c2 from t2)) from t1;
explain format="dot" select sum(t1.c1 in (select c1 from t2)) from t1;
explain format="dot" select 1 in (select c2 from t2) from t1;
drop table if exists t1, t2, t3, t4;
drop table if exists t;
create table t(a int primary key, b int, c int, index idx(b));
explain select t.c in (select count(*) from t s ignore index(idx), t t1 where s.a = t.a and s.a = t1.a) from t;
explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.a = t1.a) from t;
explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.c = t1.a) from t;
drop table if exists t;
create table t(a int unsigned);
explain select t.a = '123455' from t;
explain select t.a > '123455' from t;
explain select t.a != '123455' from t;
explain select t.a = 12345678912345678998789678687678.111 from t;
drop table if exists t;
create table t(a bigint, b bigint, index idx(a, b));
explain select * from t where a in (1, 2) and a in (1, 3);
explain select * from t where b in (1, 2) and b in (1, 3);
explain select * from t where a = 1 and a = 1;
explain select * from t where a = 1 and a = 2;
explain select * from t where b = 1 and b = 2;
explain select * from t t1 join t t2 where t1.b = t2.b and t2.b is null;
explain select * from t t1 where not exists (select * from t t2 where t1.b = t2.b);
drop table if exists t;
create table t(a bigint primary key);
explain select * from t where a = 1 and a = 2;
explain select null or a > 1 from t;
drop table if exists ta, tb;
create table ta (a varchar(20));
create table tb (a varchar(20));
begin;
insert tb values ('1');
explain select * from ta where a = 1;
rollback;
# https://github.com/pingcap/tidb/issues/7918
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;
explain select ifnull(nb, 0) from t;
explain select ifnull(nb, 0), ifnull(nc, 0) from t;
explain select ifnull(a, 0), ifnull(nb, 0) from t;
explain select ifnull(nb, 0), ifnull(nb, 0) from t;
explain select 1+ifnull(nb, 0) from t;
explain select 1+ifnull(a, 0) from t;
drop table if exists t;
drop table if exists t;
create table t(a int);
explain select * from t where _tidb_rowid = 0;
explain select * from t where _tidb_rowid > 0;
explain select a, _tidb_rowid from t where a > 0;
explain select * from t where _tidb_rowid > 0 and a > 0;
drop table if exists t;