From f052e64103d49cf9c3344ddaa2e157ceaeda91c2 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 9 Apr 2022 18:12:53 +0800 Subject: [PATCH] feature/qnode --- tests/script/general/explain/explain.sim | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/script/general/explain/explain.sim diff --git a/tests/script/general/explain/explain.sim b/tests/script/general/explain/explain.sim new file mode 100644 index 0000000000..666e4040b7 --- /dev/null +++ b/tests/script/general/explain/explain.sim @@ -0,0 +1,102 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 +sql create database db1 vgroups 3; +sql use db1; +sql show databases; +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)"); + +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)"); + + +print ======== step2 +sql explain select * from st1 where -2; +sql explain select ts from tb1; +sql explain select * from st1; +sql explain select * from st1 order by ts; +sql explain select * from information_schema.user_stables; +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; +sql explain select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +sql explain select min(f1) from st1 interval(1m, 2a) sliding(3n); + +print ======== step3 +sql explain verbose true select * from st1 where -2; +sql explain verbose true select ts from tb1 where f1 > 0; +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'; +sql explain verbose true select * from information_schema.user_stables where db_name='db2'; +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; + +print ======== step4 +sql explain analyze select ts from st1 where -2; +sql explain analyze select ts from tb1; +sql explain analyze select ts from st1; +sql explain analyze select ts from st1; +sql explain analyze select ts from st1 order by ts; +sql explain analyze select * from information_schema.user_stables; +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; +sql explain analyze select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +sql explain analyze select min(f1) from st1 interval(3n, 2a) sliding(1n); + +print ======== step5 +sql explain analyze verbose true select ts from st1 where -2; +sql explain analyze verbose true select ts from tb1; +sql explain analyze verbose true select ts from st1; +sql explain analyze verbose true select ts from st1; +sql explain analyze verbose true select ts from st1 order by ts; +sql explain analyze verbose true select * from information_schema.user_stables; +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; +sql explain analyze verbose true select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +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'; +sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2'; +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; +sql explain analyze verbose true select min(f1) from st1 interval(3n, 2a) sliding(1n); +sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0; + +#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; +#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(1s, 2d) 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(3n) fill(linear) order by ts; +#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); + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file -- GitLab