You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: benchmarks/queries/clickbench/queries.sql
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ SELECT SUM("AdvEngineID"), COUNT(*), AVG("ResolutionWidth") FROM hits;
4
4
SELECTAVG("UserID") FROM hits;
5
5
SELECTCOUNT(DISTINCT "UserID") FROM hits;
6
6
SELECTCOUNT(DISTINCT "SearchPhrase") FROM hits;
7
-
SELECTMIN("EventDate"::INT::DATE), MAX("EventDate"::INT::DATE) FROM hits;
7
+
SELECTMIN("EventDate"), MAX("EventDate") FROM hits;
8
8
SELECT"AdvEngineID", COUNT(*) FROM hits WHERE"AdvEngineID"<>0GROUP BY"AdvEngineID"ORDER BYCOUNT(*) DESC;
9
9
SELECT"RegionID", COUNT(DISTINCT "UserID") AS u FROM hits GROUP BY"RegionID"ORDER BY u DESCLIMIT10;
10
10
SELECT"RegionID", SUM("AdvEngineID"), COUNT(*) AS c, AVG("ResolutionWidth"), COUNT(DISTINCT "UserID") FROM hits GROUP BY"RegionID"ORDER BY c DESCLIMIT10;
SELECT"URL", COUNT(*) AS c FROM hits GROUP BY"URL"ORDER BY c DESCLIMIT10;
35
35
SELECT1, "URL", COUNT(*) AS c FROM hits GROUP BY1, "URL"ORDER BY c DESCLIMIT10;
36
36
SELECT"ClientIP", "ClientIP"-1, "ClientIP"-2, "ClientIP"-3, COUNT(*) AS c FROM hits GROUP BY"ClientIP", "ClientIP"-1, "ClientIP"-2, "ClientIP"-3ORDER BY c DESCLIMIT10;
37
-
SELECT"URL", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-01'AND"EventDate"::INT::DATE<='2013-07-31'AND"DontCountHits"=0AND"IsRefresh"=0AND"URL"<>''GROUP BY"URL"ORDER BY PageViews DESCLIMIT10;
38
-
SELECT"Title", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-01'AND"EventDate"::INT::DATE<='2013-07-31'AND"DontCountHits"=0AND"IsRefresh"=0AND"Title"<>''GROUP BY"Title"ORDER BY PageViews DESCLIMIT10;
39
-
SELECT"URL", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-01'AND"EventDate"::INT::DATE<='2013-07-31'AND"IsRefresh"=0AND"IsLink"<>0AND"IsDownload"=0GROUP BY"URL"ORDER BY PageViews DESCLIMIT10 OFFSET 1000;
40
-
SELECT"TraficSourceID", "SearchEngineID", "AdvEngineID", CASE WHEN ("SearchEngineID"=0AND"AdvEngineID"=0) THEN "Referer" ELSE '' END AS Src, "URL"AS Dst, COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-01'AND"EventDate"::INT::DATE<='2013-07-31'AND"IsRefresh"=0GROUP BY"TraficSourceID", "SearchEngineID", "AdvEngineID", Src, Dst ORDER BY PageViews DESCLIMIT10 OFFSET 1000;
41
-
SELECT"URLHash", "EventDate"::INT::DATE, COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-01'AND"EventDate"::INT::DATE<='2013-07-31'AND"IsRefresh"=0AND"TraficSourceID"IN (-1, 6) AND"RefererHash"=3594120000172545465GROUP BY"URLHash", "EventDate"::INT::DATEORDER BY PageViews DESCLIMIT10 OFFSET 100;
42
-
SELECT"WindowClientWidth", "WindowClientHeight", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-01'AND"EventDate"::INT::DATE<='2013-07-31'AND"IsRefresh"=0AND"DontCountHits"=0AND"URLHash"=2868770270353813622GROUP BY"WindowClientWidth", "WindowClientHeight"ORDER BY PageViews DESCLIMIT10 OFFSET 10000;
43
-
SELECT DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) AS M, COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate"::INT::DATE>='2013-07-14'AND"EventDate"::INT::DATE<='2013-07-15'AND"IsRefresh"=0AND"DontCountHits"=0GROUP BY DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) ORDER BY DATE_TRUNC('minute', M) LIMIT10 OFFSET 1000;
37
+
SELECT"URL", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-01'AND"EventDate"<='2013-07-31'AND"DontCountHits"=0AND"IsRefresh"=0AND"URL"<>''GROUP BY"URL"ORDER BY PageViews DESCLIMIT10;
38
+
SELECT"Title", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-01'AND"EventDate"<='2013-07-31'AND"DontCountHits"=0AND"IsRefresh"=0AND"Title"<>''GROUP BY"Title"ORDER BY PageViews DESCLIMIT10;
39
+
SELECT"URL", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-01'AND"EventDate"<='2013-07-31'AND"IsRefresh"=0AND"IsLink"<>0AND"IsDownload"=0GROUP BY"URL"ORDER BY PageViews DESCLIMIT10 OFFSET 1000;
40
+
SELECT"TraficSourceID", "SearchEngineID", "AdvEngineID", CASE WHEN ("SearchEngineID"=0AND"AdvEngineID"=0) THEN "Referer" ELSE '' END AS Src, "URL"AS Dst, COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-01'AND"EventDate"<='2013-07-31'AND"IsRefresh"=0GROUP BY"TraficSourceID", "SearchEngineID", "AdvEngineID", Src, Dst ORDER BY PageViews DESCLIMIT10 OFFSET 1000;
41
+
SELECT"URLHash", "EventDate", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-01'AND"EventDate"<='2013-07-31'AND"IsRefresh"=0AND"TraficSourceID"IN (-1, 6) AND"RefererHash"=3594120000172545465GROUP BY"URLHash", "EventDate"ORDER BY PageViews DESCLIMIT10 OFFSET 100;
42
+
SELECT"WindowClientWidth", "WindowClientHeight", COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-01'AND"EventDate"<='2013-07-31'AND"IsRefresh"=0AND"DontCountHits"=0AND"URLHash"=2868770270353813622GROUP BY"WindowClientWidth", "WindowClientHeight"ORDER BY PageViews DESCLIMIT10 OFFSET 10000;
43
+
SELECT DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) AS M, COUNT(*) AS PageViews FROM hits WHERE"CounterID"=62AND"EventDate">='2013-07-14'AND"EventDate"<='2013-07-15'AND"IsRefresh"=0AND"DontCountHits"=0GROUP BY DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) ORDER BY DATE_TRUNC('minute', M) LIMIT10 OFFSET 1000;
SELECT * FROM hits WHERE "URL" LIKE '%google%' ORDER BY to_timestamp_seconds("EventTime") LIMIT 10;
171
+
SELECT * FROM hits WHERE "URL" LIKE '%google%' ORDER BY "EventTime" LIMIT 10;
172
172
----
173
173
174
174
query T
175
-
SELECT "SearchPhrase" FROM hits WHERE "SearchPhrase" <> '' ORDER BY to_timestamp_seconds("EventTime") LIMIT 10;
175
+
SELECT "SearchPhrase" FROM hits WHERE "SearchPhrase" <> '' ORDER BY "EventTime" LIMIT 10;
176
176
----
177
177
178
178
query T
179
179
SELECT "SearchPhrase" FROM hits WHERE "SearchPhrase" <> '' ORDER BY "SearchPhrase" LIMIT 10;
180
180
----
181
181
182
182
query T
183
-
SELECT "SearchPhrase" FROM hits WHERE "SearchPhrase" <> '' ORDER BY to_timestamp_seconds("EventTime"), "SearchPhrase" LIMIT 10;
183
+
SELECT "SearchPhrase" FROM hits WHERE "SearchPhrase" <> '' ORDER BY "EventTime", "SearchPhrase" LIMIT 10;
184
184
----
185
185
186
186
query IRI
@@ -247,31 +247,31 @@ SELECT "ClientIP", "ClientIP" - 1, "ClientIP" - 2, "ClientIP" - 3, COUNT(*) AS c
247
247
1615432634 1615432633 1615432632 1615432631 1
248
248
249
249
query TI
250
-
SELECT "URL", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-01' AND "EventDate"::INT::DATE <= '2013-07-31' AND "DontCountHits" = 0 AND "IsRefresh" = 0 AND "URL" <> '' GROUP BY "URL" ORDER BY PageViews DESC LIMIT 10;
250
+
SELECT "URL", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-01' AND "EventDate" <= '2013-07-31' AND "DontCountHits" = 0 AND "IsRefresh" = 0 AND "URL" <> '' GROUP BY "URL" ORDER BY PageViews DESC LIMIT 10;
251
251
----
252
252
253
253
query TI
254
-
SELECT "Title", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-01' AND "EventDate"::INT::DATE <= '2013-07-31' AND "DontCountHits" = 0 AND "IsRefresh" = 0 AND "Title" <> '' GROUP BY "Title" ORDER BY PageViews DESC LIMIT 10;
254
+
SELECT "Title", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-01' AND "EventDate" <= '2013-07-31' AND "DontCountHits" = 0 AND "IsRefresh" = 0 AND "Title" <> '' GROUP BY "Title" ORDER BY PageViews DESC LIMIT 10;
255
255
----
256
256
257
257
query TI
258
-
SELECT "URL", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-01' AND "EventDate"::INT::DATE <= '2013-07-31' AND "IsRefresh" = 0 AND "IsLink" <> 0 AND "IsDownload" = 0 GROUP BY "URL" ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;
258
+
SELECT "URL", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-01' AND "EventDate" <= '2013-07-31' AND "IsRefresh" = 0 AND "IsLink" <> 0 AND "IsDownload" = 0 GROUP BY "URL" ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;
259
259
----
260
260
261
261
query IIITTI
262
-
SELECT "TraficSourceID", "SearchEngineID", "AdvEngineID", CASE WHEN ("SearchEngineID" = 0 AND "AdvEngineID" = 0) THEN "Referer" ELSE '' END AS Src, "URL" AS Dst, COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-01' AND "EventDate"::INT::DATE <= '2013-07-31' AND "IsRefresh" = 0 GROUP BY "TraficSourceID", "SearchEngineID", "AdvEngineID", Src, Dst ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;
262
+
SELECT "TraficSourceID", "SearchEngineID", "AdvEngineID", CASE WHEN ("SearchEngineID" = 0 AND "AdvEngineID" = 0) THEN "Referer" ELSE '' END AS Src, "URL" AS Dst, COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-01' AND "EventDate" <= '2013-07-31' AND "IsRefresh" = 0 GROUP BY "TraficSourceID", "SearchEngineID", "AdvEngineID", Src, Dst ORDER BY PageViews DESC LIMIT 10 OFFSET 1000;
263
263
----
264
264
265
-
query IDI
266
-
SELECT "URLHash", "EventDate"::INT::DATE, COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-01' AND "EventDate"::INT::DATE <= '2013-07-31' AND "IsRefresh" = 0 AND "TraficSourceID" IN (-1, 6) AND "RefererHash" = 3594120000172545465 GROUP BY "URLHash", "EventDate"::INT::DATE ORDER BY PageViews DESC LIMIT 10 OFFSET 100;
265
+
query III
266
+
SELECT "URLHash", "EventDate", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-01' AND "EventDate" <= '2013-07-31' AND "IsRefresh" = 0 AND "TraficSourceID" IN (-1, 6) AND "RefererHash" = 3594120000172545465 GROUP BY "URLHash", "EventDate" ORDER BY PageViews DESC LIMIT 10 OFFSET 100;
267
267
----
268
268
269
269
query III
270
-
SELECT "WindowClientWidth", "WindowClientHeight", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-01' AND "EventDate"::INT::DATE <= '2013-07-31' AND "IsRefresh" = 0 AND "DontCountHits" = 0 AND "URLHash" = 2868770270353813622 GROUP BY "WindowClientWidth", "WindowClientHeight" ORDER BY PageViews DESC LIMIT 10 OFFSET 10000;
270
+
SELECT "WindowClientWidth", "WindowClientHeight", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-01' AND "EventDate" <= '2013-07-31' AND "IsRefresh" = 0 AND "DontCountHits" = 0 AND "URLHash" = 2868770270353813622 GROUP BY "WindowClientWidth", "WindowClientHeight" ORDER BY PageViews DESC LIMIT 10 OFFSET 10000;
271
271
----
272
272
273
273
query PI
274
-
SELECT DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) AS M, COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate"::INT::DATE >= '2013-07-14' AND "EventDate"::INT::DATE <= '2013-07-15' AND "IsRefresh" = 0 AND "DontCountHits" = 0 GROUP BY DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) ORDER BY DATE_TRUNC('minute', M) LIMIT 10 OFFSET 1000;
274
+
SELECT DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) AS M, COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND "EventDate" >= '2013-07-14' AND "EventDate" <= '2013-07-15' AND "IsRefresh" = 0 AND "DontCountHits" = 0 GROUP BY DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) ORDER BY DATE_TRUNC('minute', M) LIMIT 10 OFFSET 1000;
275
275
----
276
276
277
277
# Clickbench "Extended" queries that test count distinct
0 commit comments