From 6adb7900cbe98a14b98c81375ab1ec74dc2d4fe7 Mon Sep 17 00:00:00 2001 From: taozizhuo Date: Mon, 5 Dec 2022 14:28:29 -0800 Subject: [PATCH] add benchmark queries --- benchmark/quries/Aquery/load_data.a | 6 ++++++ benchmark/quries/Aquery/q0.a | 5 +++++ benchmark/quries/Aquery/q1.a | 7 +++++++ benchmark/quries/Aquery/q10.a | 4 ++++ benchmark/quries/Aquery/q2.a | 4 ++++ benchmark/quries/Aquery/q3.a | 7 +++++++ benchmark/quries/Aquery/q4.a | 5 +++++ benchmark/quries/Aquery/q7.a | 5 +++++ benchmark/quries/Aquery/q8.a | 6 ++++++ benchmark/quries/Aquery/q9.a | 6 ++++++ benchmark/quries/Clickhouse/q0 | 3 +++ benchmark/quries/Clickhouse/q1 | 4 ++++ benchmark/quries/Clickhouse/q10 | 8 ++++++++ benchmark/quries/Clickhouse/q2 | 2 ++ benchmark/quries/Clickhouse/q3 | 4 ++++ benchmark/quries/Clickhouse/q4 | 2 ++ benchmark/quries/Clickhouse/q7 | 5 +++++ benchmark/quries/Clickhouse/q8 | 3 +++ benchmark/quries/Clickhouse/q9 | 3 +++ benchmark/quries/Timescaledb/q0 | 3 +++ benchmark/quries/Timescaledb/q1 | 4 ++++ benchmark/quries/Timescaledb/q10 | 7 +++++++ benchmark/quries/Timescaledb/q2 | 2 ++ benchmark/quries/Timescaledb/q3 | 4 ++++ benchmark/quries/Timescaledb/q4 | 2 ++ benchmark/quries/Timescaledb/q7 | 5 +++++ benchmark/quries/Timescaledb/q8 | 3 +++ benchmark/quries/Timescaledb/q9 | 3 +++ 28 files changed, 122 insertions(+) create mode 100644 benchmark/quries/Aquery/load_data.a create mode 100644 benchmark/quries/Aquery/q0.a create mode 100644 benchmark/quries/Aquery/q1.a create mode 100644 benchmark/quries/Aquery/q10.a create mode 100644 benchmark/quries/Aquery/q2.a create mode 100644 benchmark/quries/Aquery/q3.a create mode 100644 benchmark/quries/Aquery/q4.a create mode 100644 benchmark/quries/Aquery/q7.a create mode 100644 benchmark/quries/Aquery/q8.a create mode 100644 benchmark/quries/Aquery/q9.a create mode 100644 benchmark/quries/Clickhouse/q0 create mode 100644 benchmark/quries/Clickhouse/q1 create mode 100644 benchmark/quries/Clickhouse/q10 create mode 100644 benchmark/quries/Clickhouse/q2 create mode 100644 benchmark/quries/Clickhouse/q3 create mode 100644 benchmark/quries/Clickhouse/q4 create mode 100644 benchmark/quries/Clickhouse/q7 create mode 100644 benchmark/quries/Clickhouse/q8 create mode 100644 benchmark/quries/Clickhouse/q9 create mode 100644 benchmark/quries/Timescaledb/q0 create mode 100644 benchmark/quries/Timescaledb/q1 create mode 100644 benchmark/quries/Timescaledb/q10 create mode 100644 benchmark/quries/Timescaledb/q2 create mode 100644 benchmark/quries/Timescaledb/q3 create mode 100644 benchmark/quries/Timescaledb/q4 create mode 100644 benchmark/quries/Timescaledb/q7 create mode 100644 benchmark/quries/Timescaledb/q8 create mode 100644 benchmark/quries/Timescaledb/q9 diff --git a/benchmark/quries/Aquery/load_data.a b/benchmark/quries/Aquery/load_data.a new file mode 100644 index 0000000..54bc36f --- /dev/null +++ b/benchmark/quries/Aquery/load_data.a @@ -0,0 +1,6 @@ +CREATE TABLE trade01m(stocksymbol STRING, time INT, quantity INT, price INT) +load data infile "../tables/trade01m.csv" into table trade01m fields terminated by ',' +CREATE TABLE trade1m(stocksymbol STRING, time INT, quantity INT, price INT) +load data infile "../tables/trade1m.csv" into table trade1m fields terminated by ',' +CREATE TABLE trade10m(stocksymbol STRING, time INT, quantity INT, price INT) +load data infile "../tables/trade10m.csv" into table trade10m fields terminated by ',' \ No newline at end of file diff --git a/benchmark/quries/Aquery/q0.a b/benchmark/quries/Aquery/q0.a new file mode 100644 index 0000000..a18deec --- /dev/null +++ b/benchmark/quries/Aquery/q0.a @@ -0,0 +1,5 @@ +-- select rows + +CREATE TABLE res0 AS +SELECT * FROM trade10m + \ No newline at end of file diff --git a/benchmark/quries/Aquery/q1.a b/benchmark/quries/Aquery/q1.a new file mode 100644 index 0000000..f3077a9 --- /dev/null +++ b/benchmark/quries/Aquery/q1.a @@ -0,0 +1,7 @@ +-- groupby_multi_different_functions + +CREATE TABLE res1 AS +SELECT avg(quantity) AS avg_quan, min(price) AS min_p +FROM trade1m +GROUP BY stocksymbol, time + \ No newline at end of file diff --git a/benchmark/quries/Aquery/q10.a b/benchmark/quries/Aquery/q10.a new file mode 100644 index 0000000..8c891ba --- /dev/null +++ b/benchmark/quries/Aquery/q10.a @@ -0,0 +1,4 @@ +SELECT stocksymbol, MAX(stddevs(3, price)) +FROM trade1m +ASSUMING ASC time +GROUP BY stocksymbol \ No newline at end of file diff --git a/benchmark/quries/Aquery/q2.a b/benchmark/quries/Aquery/q2.a new file mode 100644 index 0000000..28e6368 --- /dev/null +++ b/benchmark/quries/Aquery/q2.a @@ -0,0 +1,4 @@ +-- count values + +SELECT COUNT(*) FROM trade10m + \ No newline at end of file diff --git a/benchmark/quries/Aquery/q3.a b/benchmark/quries/Aquery/q3.a new file mode 100644 index 0000000..c6f7a5b --- /dev/null +++ b/benchmark/quries/Aquery/q3.a @@ -0,0 +1,7 @@ +-- group by multiple keys + +create table res3 AS +SELECT sum(quantity) as sum_quantity +FROM trade01m +GROUP BY stocksymbol, price + \ No newline at end of file diff --git a/benchmark/quries/Aquery/q4.a b/benchmark/quries/Aquery/q4.a new file mode 100644 index 0000000..bab175f --- /dev/null +++ b/benchmark/quries/Aquery/q4.a @@ -0,0 +1,5 @@ +-- append tables + +CREATE TABLE res4 AS +SELECT * FROM trade10m UNION ALL SELECT * FROM trade10m + \ No newline at end of file diff --git a/benchmark/quries/Aquery/q7.a b/benchmark/quries/Aquery/q7.a new file mode 100644 index 0000000..7e384c8 --- /dev/null +++ b/benchmark/quries/Aquery/q7.a @@ -0,0 +1,5 @@ +CREATE table res7 AS +SELECT stocksymbol, avgs(5, price) +FROM trade10m +ASSUMING ASC time +GROUP BY stocksymbol \ No newline at end of file diff --git a/benchmark/quries/Aquery/q8.a b/benchmark/quries/Aquery/q8.a new file mode 100644 index 0000000..6642520 --- /dev/null +++ b/benchmark/quries/Aquery/q8.a @@ -0,0 +1,6 @@ + +CREATE TABLE res8 AS +SELECT stocksymbol, quantity, price +FROM trade10m +WHERE time >= 5288 and time <= 7000 + \ No newline at end of file diff --git a/benchmark/quries/Aquery/q9.a b/benchmark/quries/Aquery/q9.a new file mode 100644 index 0000000..7348b8e --- /dev/null +++ b/benchmark/quries/Aquery/q9.a @@ -0,0 +1,6 @@ + +CREATE TABLE res9 AS +SELECT stocksymbol, MAX(price) - MIN(price) +FROM trade10m +GROUP BY stocksymbol + \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q0 b/benchmark/quries/Clickhouse/q0 new file mode 100644 index 0000000..e06e534 --- /dev/null +++ b/benchmark/quries/Clickhouse/q0 @@ -0,0 +1,3 @@ +-- q0 select rows +CREATE TABLE res0 (a String, b Int32, c Int32, d Int32) ENGINE = MergeTree() ORDER BY b AS +SELECT * FROM benchmark.trade10m \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q1 b/benchmark/quries/Clickhouse/q1 new file mode 100644 index 0000000..21ef83b --- /dev/null +++ b/benchmark/quries/Clickhouse/q1 @@ -0,0 +1,4 @@ +-- groupby_multi_different_functions +SELECT avg(quantity), min(price) +FROM benchmark.trade10m +GROUP BY stocksymbol, time \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q10 b/benchmark/quries/Clickhouse/q10 new file mode 100644 index 0000000..c251cb6 --- /dev/null +++ b/benchmark/quries/Clickhouse/q10 @@ -0,0 +1,8 @@ +-- max rolling std +select + stocksymbol, + max(stddevPop(price)) over + (partition by stocksymbol rows between 2 preceding AND CURRENT row) as maxRollingStd +from +(SELECT * FROM benchmark.trade01m ORDER BY time) +GROUP BY stocksymbol \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q2 b/benchmark/quries/Clickhouse/q2 new file mode 100644 index 0000000..1267934 --- /dev/null +++ b/benchmark/quries/Clickhouse/q2 @@ -0,0 +1,2 @@ +-- count values +SELECT COUNT(*) FROM benchmark.trade10m \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q3 b/benchmark/quries/Clickhouse/q3 new file mode 100644 index 0000000..79ea85e --- /dev/null +++ b/benchmark/quries/Clickhouse/q3 @@ -0,0 +1,4 @@ +-- group by multiple keys +SELECT sum(quantity) +FROM benchmark.trade10m +GROUP BY stocksymbol, price \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q4 b/benchmark/quries/Clickhouse/q4 new file mode 100644 index 0000000..016f3fc --- /dev/null +++ b/benchmark/quries/Clickhouse/q4 @@ -0,0 +1,2 @@ +-- append two tables +SELECT * FROM benchmark.trade10m UNION ALL SELECT * FROM benchmark.trade10m \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q7 b/benchmark/quries/Clickhouse/q7 new file mode 100644 index 0000000..ed57058 --- /dev/null +++ b/benchmark/quries/Clickhouse/q7 @@ -0,0 +1,5 @@ +-- moving_avg +SELECT stocksymbol, groupArrayMovingAvg(5)(price) AS moving_avg_price +FROM +(SELECT * FROM benchmark.trade01m ORDER BY time) +GROUP BY stocksymbol \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q8 b/benchmark/quries/Clickhouse/q8 new file mode 100644 index 0000000..550abbd --- /dev/null +++ b/benchmark/quries/Clickhouse/q8 @@ -0,0 +1,3 @@ +SELECT stocksymbol, quantity, price +FROM benchmark.trade10m +WHERE time >= 5288 and time <= 7000 \ No newline at end of file diff --git a/benchmark/quries/Clickhouse/q9 b/benchmark/quries/Clickhouse/q9 new file mode 100644 index 0000000..48312c9 --- /dev/null +++ b/benchmark/quries/Clickhouse/q9 @@ -0,0 +1,3 @@ +SELECT stocksymbol, MAX(price) - MIN(price) +FROM benchmark.trade1m +GROUP BY stocksymbol \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q0 b/benchmark/quries/Timescaledb/q0 new file mode 100644 index 0000000..b6dec8f --- /dev/null +++ b/benchmark/quries/Timescaledb/q0 @@ -0,0 +1,3 @@ +-- select rows +CREATE TABLE res0 AS +SELECT * FROM trade10m; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q1 b/benchmark/quries/Timescaledb/q1 new file mode 100644 index 0000000..0ac4c46 --- /dev/null +++ b/benchmark/quries/Timescaledb/q1 @@ -0,0 +1,4 @@ +-- groupby_multi_different_functions +SELECT avg(quantity), min(price) +FROM trade10m +GROUP BY stocksymbol, time; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q10 b/benchmark/quries/Timescaledb/q10 new file mode 100644 index 0000000..6d4b326 --- /dev/null +++ b/benchmark/quries/Timescaledb/q10 @@ -0,0 +1,7 @@ +select + stocksymbol, + max(stddev(price)) over + (partition by stocksymbol rows between 2 preceding AND CURRENT row) as maxRollingStd +from +(SELECT * FROM trade01m ORDER BY time) as t +GROUP BY stocksymbol; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q2 b/benchmark/quries/Timescaledb/q2 new file mode 100644 index 0000000..b1f00f6 --- /dev/null +++ b/benchmark/quries/Timescaledb/q2 @@ -0,0 +1,2 @@ +-- count values +SELECT COUNT(*) FROM trade10m; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q3 b/benchmark/quries/Timescaledb/q3 new file mode 100644 index 0000000..0176182 --- /dev/null +++ b/benchmark/quries/Timescaledb/q3 @@ -0,0 +1,4 @@ +-- group by multiple keys +SELECT sum(quantity) +FROM trade10m +GROUP BY stocksymbol, price; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q4 b/benchmark/quries/Timescaledb/q4 new file mode 100644 index 0000000..a3e7f14 --- /dev/null +++ b/benchmark/quries/Timescaledb/q4 @@ -0,0 +1,2 @@ +-- append tables +SELECT * FROM trade10m UNION ALL SELECT * FROM trade10m; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q7 b/benchmark/quries/Timescaledb/q7 new file mode 100644 index 0000000..c0aa976 --- /dev/null +++ b/benchmark/quries/Timescaledb/q7 @@ -0,0 +1,5 @@ +select + stocksymbol, + coalesce(avg(price) over + (partition by stocksymbol order by time rows between 4 preceding AND CURRENT row), price) as rollingAvg +from trade10m; \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q8 b/benchmark/quries/Timescaledb/q8 new file mode 100644 index 0000000..db6be13 --- /dev/null +++ b/benchmark/quries/Timescaledb/q8 @@ -0,0 +1,3 @@ +SELECT stocksymbol, quantity, price +FROM trade01m +WHERE time >= 5288 and time <= 7000 \ No newline at end of file diff --git a/benchmark/quries/Timescaledb/q9 b/benchmark/quries/Timescaledb/q9 new file mode 100644 index 0000000..e8c0b92 --- /dev/null +++ b/benchmark/quries/Timescaledb/q9 @@ -0,0 +1,3 @@ +SELECT stocksymbol, MAX(price) - MIN(price) +FROM trade01m +GROUP BY stocksymbol; \ No newline at end of file