explain.sim 9.2 KB
Newer Older
D
dapan1121 已提交
1 2 3 4 5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect

6
print ======== step1
7
sql create database db1 vgroups 3 cachesize 10 cachemodel 'both';
D
dapan1121 已提交
8
sql use db1;
X
Xiaoyu Wang 已提交
9
sql select * from information_schema.ins_databases;
D
dapan1121 已提交
10 11 12 13 14 15 16 17 18 19 20 21
sql create stable st1 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int);
sql create stable st2 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int);
sql create table tb1 using st1 tags(1);
sql insert into tb1 values (now, 1, "Hash Join  (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)");

sql create table tb2 using st1 tags(2);
sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2  (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)");
sql create table tb3 using st1 tags(3);
sql insert into tb3 values (now, 3, "Hash  (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)");
sql create table tb4 using st1 tags(4);
sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1  (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");

22 23 24 25 26 27 28 29 30
#sql create table tb1 using st2 tags(1);
#sql insert into tb1 values (now, 1, "Hash Join  (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)");

#sql create table tb2 using st2 tags(2);
#sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2  (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)");
#sql create table tb3 using st2 tags(3);
#sql insert into tb3 values (now, 3, "Hash  (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)");
#sql create table tb4 using st2 tags(4);
#sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1  (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");
D
dapan1121 已提交
31

X
Xiaoyu Wang 已提交
32 33
# for explain insert into select
sql create table t1 (ts timestamp, f1 int, f2 binary(200), t1 int);
D
dapan1121 已提交
34

35
print ======== step2
D
dapan1121 已提交
36
sql explain select * from st1 where -2;
X
Xiaoyu Wang 已提交
37
sql explain insert into t1 select * from st1 where -2;
D
dapan1121 已提交
38
sql explain select ts from tb1;
X
Xiaoyu Wang 已提交
39
sql explain insert into t1(ts) select ts from tb1;
D
dapan1121 已提交
40
sql explain select * from st1;
X
Xiaoyu Wang 已提交
41
sql explain insert into t1 select * from st1;
D
dapan1121 已提交
42
sql explain select * from st1 order by ts;
X
Xiaoyu Wang 已提交
43
sql explain insert into t1 select * from st1 order by ts;
D
dapan1121 已提交
44
sql explain select * from information_schema.ins_stables;
D
dapan1121 已提交
45 46 47
sql explain select count(*),sum(f1) from tb1;
sql explain select count(*),sum(f1) from st1;
sql explain select count(*),sum(f1) from st1 group by f1;
48
#sql explain select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
X
Xiaoyu Wang 已提交
49
sql explain insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s);
D
dapan1121 已提交
50

51
print ======== step3
D
dapan1121 已提交
52
sql explain verbose true select * from st1 where -2;
X
Xiaoyu Wang 已提交
53
sql explain verbose true insert into t1 select * from st1 where -2;
D
dapan1121 已提交
54
sql explain verbose true select ts from tb1 where f1 > 0;
X
Xiaoyu Wang 已提交
55
sql explain verbose true insert into t1(ts) select ts from tb1 where f1 > 0;
D
dapan1121 已提交
56
sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
X
Xiaoyu Wang 已提交
57
sql explain verbose true insert into t1 select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
D
dapan1121 已提交
58
sql explain verbose true select count(*) from st1 partition by tbname slimit 1 soffset 2 limit 2 offset 1;
D
dapan1121 已提交
59
sql explain verbose true select * from information_schema.ins_stables where db_name='db2';
D
dapan1121 已提交
60
sql explain verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0;
X
Xiaoyu Wang 已提交
61 62
sql explain verbose true insert into t1(ts) select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0;
sql explain verbose true insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s);
63 64 65 66 67 68 69 70 71
sql explain verbose true select distinct tbname, table_name from information_schema.ins_tables;
sql explain verbose true select diff(f1) as f11 from tb1 order by f11;
sql explain verbose true select count(*) from st1 where ts > now - 3m and ts < now interval(10s) fill(linear);
sql explain verbose true select count(*) from st1 partition by tbname;
sql explain verbose true select count(*) from information_schema.ins_tables group by stable_name;
sql explain verbose true select last(*) from st1;
sql explain verbose true select last_row(*) from st1;
sql explain verbose true select interp(f1) from tb1 where ts > now - 3m and ts < now range(now-3m,now) every(1m) fill(prev);
sql explain verbose true select _wstart, _wend, count(*) from tb1 EVENT_WINDOW start with f1 > 0 end with f1 < 10;
D
dapan1121 已提交
72

73
print ======== step4
D
dapan1121 已提交
74
sql explain analyze select ts from st1 where -2;
X
Xiaoyu Wang 已提交
75
sql explain analyze insert into t1(ts) select ts from st1 where -2;
D
dapan1121 已提交
76
sql explain analyze select ts from tb1;
X
Xiaoyu Wang 已提交
77
sql explain analyze insert into t1(ts) select ts from tb1;
D
dapan1121 已提交
78
sql explain analyze select ts from st1;
X
Xiaoyu Wang 已提交
79
sql explain analyze insert into t1(ts) select ts from st1;
D
dapan1121 已提交
80
sql explain analyze select ts from st1 order by ts;
X
Xiaoyu Wang 已提交
81
sql explain analyze insert into t1(ts) select ts from st1 order by ts;
D
dapan1121 已提交
82
sql explain analyze select * from information_schema.ins_stables;
D
dapan1121 已提交
83 84 85
sql explain analyze select count(*),sum(f1) from tb1;
sql explain analyze select count(*),sum(f1) from st1;
sql explain analyze select count(*),sum(f1) from st1 group by f1;
X
Xiaoyu Wang 已提交
86
sql explain analyze insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s);
D
dapan1121 已提交
87

88
print ======== step5
D
dapan1121 已提交
89
sql explain analyze verbose true select ts from st1 where -2;
X
Xiaoyu Wang 已提交
90
sql explain analyze verbose true insert into t1(ts) select ts from st1 where -2;
D
dapan1121 已提交
91
sql explain analyze verbose true select ts from tb1;
X
Xiaoyu Wang 已提交
92
sql explain analyze verbose true insert into t1(ts) select ts from tb1;
D
dapan1121 已提交
93
sql explain analyze verbose true select ts from st1;
X
Xiaoyu Wang 已提交
94
sql explain analyze verbose true insert into t1(ts) select ts from st1;
D
dapan1121 已提交
95
sql explain analyze verbose true select ts from st1 order by ts;
X
Xiaoyu Wang 已提交
96
sql explain analyze verbose true insert into t1(ts) select ts from st1 order by ts;
D
dapan1121 已提交
97
sql explain analyze verbose true select * from information_schema.ins_stables;
D
dapan1121 已提交
98 99 100
sql explain analyze verbose true select count(*),sum(f1) from tb1;
sql explain analyze verbose true select count(*),sum(f1) from st1;
sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1;
101
#sql explain analyze verbose true select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
D
dapan1121 已提交
102 103
sql explain analyze verbose true select ts from tb1 where f1 > 0;
sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
D
dapan1121 已提交
104
sql explain analyze verbose true select * from information_schema.ins_stables where db_name='db2';
D
dapan1121 已提交
105
sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0;
106
sql explain analyze verbose true select count(f1) from st1 group by tbname;
D
dapan1121 已提交
107
sql explain analyze verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0;
108 109 110 111 112 113 114
sql explain analyze verbose true select diff(f1) as f11 from tb1 order by f11;
sql explain analyze verbose true select count(*) from st1 where ts > now - 3m and ts < now interval(10s) fill(linear);
sql explain analyze verbose true select count(*) from information_schema.ins_tables group by stable_name;
sql explain analyze verbose true select last(*) from st1;
sql explain analyze verbose true select last_row(*) from st1;
sql explain analyze verbose true select interp(f1) from tb1 where ts > now - 3m and ts < now range(now-3m,now) every(1m) fill(prev);
sql explain analyze verbose true select _wstart, _wend, count(*) from tb1 EVENT_WINDOW start with f1 > 0 end with f1 < 10;
D
dapan1121 已提交
115 116 117 118 119

#not pass case
#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa;
#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
X
Xiaoyu Wang 已提交
120 121
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(10s, 2s) sliding(3s) order by ts;
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(30s)  fill(linear) order by ts;
D
dapan1121 已提交
122 123 124 125 126
#sql explain select max(f1) from tb1 SESSION(ts, 1s);
#sql explain select max(f1) from st1 SESSION(ts, 1s);
#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts;
#sql explain select * from st1, st2 where tb1.ts=tb2.ts;
#sql explain analyze verbose true select sum(a+b) from (select _rowts, min(f1) b,count(*) a from st1 where f1 > 0 interval(1a)) where a < 0 interval(1s);
127
#sql explain select min(f1) from st1 interval(1m, 2a) sliding(30s);
G
Ganlin Zhao 已提交
128
#sql explain verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
129
#sql explain analyze select min(f1) from st1 interval(3m, 2a) sliding(1m);
G
Ganlin Zhao 已提交
130 131
#sql explain analyze select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
#sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
132
#sql explain analyze verbose true select min(f1) from st1 interval(3m, 2a) sliding(1m);
D
dapan1121 已提交
133 134


D
dapan1121 已提交
135
#system sh/exec.sh -n dnode1 -s stop -x SIGINT