Skip to content

Commit

Permalink
ch preview ans once per query
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Dec 17, 2020
1 parent 899fa64 commit 783a677
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions clickhouse/groupby-clickhouse.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'sum v1 by id1' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id1, sum(v1) AS v1 FROM DATA_NAME GROUP BY id1;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q1_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -35,7 +34,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'sum v1 by id1:id2' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id1, id2, sum(v1) AS v1 FROM DATA_NAME GROUP BY id1, id2;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q2_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -55,7 +53,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'sum v1 mean v3 by id3' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id3, sum(v1) AS v1, avg(v3) AS v3 FROM DATA_NAME GROUP BY id3;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q3_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -75,7 +72,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'mean v1:v3 by id4' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id4, avg(v1) AS v1, avg(v2) AS v2, avg(v3) AS v3 FROM DATA_NAME GROUP BY id4;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q4_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -95,7 +91,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'sum v1:v3 by id6' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id6, sum(v1) AS v1, sum(v2) AS v2, sum(v3) AS v3 FROM DATA_NAME GROUP BY id6;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q5_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -115,7 +110,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'median v3 sd v3 by id4 id5' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id4, id5, medianExact(v3) AS median_v3, stddevPop(v3) AS sd_v3 FROM DATA_NAME GROUP BY id4, id5;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q6_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -135,7 +129,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'max v1 - min v2 by id3' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id3, max(v1) - min(v2) AS range_v1_v2 FROM DATA_NAME GROUP BY id3;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q7_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -155,7 +148,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'largest two v3 by id6' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id6, arrayJoin(arraySlice(arrayReverseSort(groupArray(v3)), 1, 2)) AS v3 FROM (SELECT id6, v3 FROM DATA_NAME WHERE v3 IS NOT NULL) AS subq GROUP BY id6;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q8_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -175,7 +167,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'regression v1 v2 by id2 id4' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Memory AS SELECT id2, id4, pow(corr(v1, v2), 2) AS r2 FROM DATA_NAME WHERE v1 IS NOT NULL AND v2 IS NOT NULL GROUP BY id2, id4;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q9_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand All @@ -195,7 +186,6 @@ SET log_queries = 0;
SYSTEM FLUSH LOGS;
SELECT 1 AS run, toUnixTimestamp(now()) AS timestamp, 'groupby' AS task, 'DATA_NAME' AS data_name, NULL AS in_rows, 'sum v3 count by id1:id6' AS question, result_rows AS out_rows, NULL AS out_cols, 'clickhouse' AS solution, version() AS version, NULL AS git, 'select group by' AS fun, query_duration_ms/1000 AS time_sec, memory_usage/1073741824 AS mem_gb, 1 AS cache, NULL AS chk, NULL AS chk_time_sec, 1 AS on_disk
FROM system.query_log WHERE type=2 AND query='CREATE TABLE ans ENGINE = Log AS SELECT id1, id2, id3, id4, id5, id6, sum(v3) AS v3, count() AS cnt FROM DATA_NAME GROUP BY id1, id2, id3, id4, id5, id6;\n' ORDER BY query_start_time DESC LIMIT 1 INTO OUTFILE 'clickhouse/log/groupby_DATA_NAME_q10_r1.csv' FORMAT CSVWithNames;
SELECT * FROM ans LIMIT 3;
DROP TABLE ans;

SET log_queries = 1;
Expand Down

0 comments on commit 783a677

Please sign in to comment.