Skip to content

Commit

Permalink
Add Presto
Browse files Browse the repository at this point in the history
Co-authored-by: Archy-X <[email protected]>
  • Loading branch information
allenshen13 and Archy-X committed Jun 4, 2024
1 parent b95b0e9 commit dbc330c
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 0 deletions.
28 changes: 28 additions & 0 deletions presto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Presto

Presto is a distributed SQL query engine for big data.
- [Github](https://github.com/prestodb/presto)
- [Homepage](https://prestodb.io)

The benchmarks are based on Presto version `0.287`.

We assume that a Presto cluster is already running. For more information, visit [Getting Started](https://prestodb.io/getting-started/).

----------
## Steps

1. Download the parquet file and upload it to an S3 Bucket ex. s3://your-bucket/clickbench-parquet/hits/hits.parquet.
2. Create a new schema named `clickbench_parquet` in the Hive metastore (Hive catalog) and create the hits table in the new schema using the create.sql file. Modify the end of the table creation statement to use the parquet file on S3.
```
WITH (
format = 'PARQUET',
external_location = 's3a://your-bucket/clickbench-parquet/hits/'
);
```
3. Connect to the Presto coordinator and run these commands:
```
git clone https://github.com/ClickHouse/ClickBench
cd ClickBench/presto
chmod +x run.sh
./run.sh
```
107 changes: 107 additions & 0 deletions presto/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
CREATE TABLE IF NOT EXISTS hits (
CounterID INT NOT NULL,
EventDate DATE NOT NULL,
UserID BIGINT NOT NULL,
EventTime TIMESTAMP NOT NULL,
WatchID BIGINT NOT NULL,
JavaEnable SMALLINT NOT NULL,
Title VARCHAR(65535) NOT NULL,
GoodEvent SMALLINT NOT NULL,
ClientIP INT NOT NULL,
RegionID INT NOT NULL,
CounterClass SMALLINT NOT NULL,
OS SMALLINT NOT NULL,
UserAgent SMALLINT NOT NULL,
URL VARCHAR(65535) NOT NULL,
Referer VARCHAR(65535) NOT NULL,
IsRefresh SMALLINT NOT NULL,
RefererCategoryID SMALLINT NOT NULL,
RefererRegionID INT NOT NULL,
URLCategoryID SMALLINT NOT NULL,
URLRegionID INT NOT NULL,
ResolutionWidth SMALLINT NOT NULL,
ResolutionHeight SMALLINT NOT NULL,
ResolutionDepth SMALLINT NOT NULL,
FlashMajor SMALLINT NOT NULL,
FlashMinor SMALLINT NOT NULL,
FlashMinor2 VARCHAR(65535) NOT NULL,
NetMajor SMALLINT NOT NULL,
NetMinor SMALLINT NOT NULL,
UserAgentMajor SMALLINT NOT NULL,
UserAgentMinor VARCHAR(65535) NOT NULL,
CookieEnable SMALLINT NOT NULL,
JavascriptEnable SMALLINT NOT NULL,
IsMobile SMALLINT NOT NULL,
MobilePhone SMALLINT NOT NULL,
MobilePhoneModel VARCHAR(65535) NOT NULL,
Params VARCHAR(65535) NOT NULL,
IPNetworkID INT NOT NULL,
TraficSourceID SMALLINT NOT NULL,
SearchEngineID SMALLINT NOT NULL,
SearchPhrase VARCHAR(65535) NOT NULL,
AdvEngineID SMALLINT NOT NULL,
IsArtifical SMALLINT NOT NULL,
WindowClientWidth SMALLINT NOT NULL,
WindowClientHeight SMALLINT NOT NULL,
ClientTimeZone SMALLINT NOT NULL,
ClientEventTime TIMESTAMP NOT NULL,
SilverlightVersion1 SMALLINT NOT NULL,
SilverlightVersion2 SMALLINT NOT NULL,
SilverlightVersion3 INT NOT NULL,
SilverlightVersion4 SMALLINT NOT NULL,
PageCharset VARCHAR(65535) NOT NULL,
CodeVersion INT NOT NULL,
IsLink SMALLINT NOT NULL,
IsDownload SMALLINT NOT NULL,
IsNotBounce SMALLINT NOT NULL,
FUniqID BIGINT NOT NULL,
OriginalURL VARCHAR(65535) NOT NULL,
HID INT NOT NULL,
IsOldCounter SMALLINT NOT NULL,
IsEvent SMALLINT NOT NULL,
IsParameter SMALLINT NOT NULL,
DontCountHits SMALLINT NOT NULL,
WithHash SMALLINT NOT NULL,
HitColor CHAR NOT NULL,
LocalEventTime TIMESTAMP NOT NULL,
Age SMALLINT NOT NULL,
Sex SMALLINT NOT NULL,
Income SMALLINT NOT NULL,
Interests SMALLINT NOT NULL,
Robotness SMALLINT NOT NULL,
RemoteIP INT NOT NULL,
WindowName INT NOT NULL,
OpenerName INT NOT NULL,
HistoryLength SMALLINT NOT NULL,
BrowserLanguage VARCHAR(65535) NOT NULL,
BrowserCountry VARCHAR(65535) NOT NULL,
SocialNetwork VARCHAR(65535) NOT NULL,
SocialAction VARCHAR(65535) NOT NULL,
HTTPError SMALLINT NOT NULL,
SendTiming INT NOT NULL,
DNSTiming INT NOT NULL,
ConnectTiming INT NOT NULL,
ResponseStartTiming INT NOT NULL,
ResponseEndTiming INT NOT NULL,
FetchTiming INT NOT NULL,
SocialSourceNetworkID SMALLINT NOT NULL,
SocialSourcePage VARCHAR(65535) NOT NULL,
ParamPrice BIGINT NOT NULL,
ParamOrderID VARCHAR(65535) NOT NULL,
ParamCurrency VARCHAR(65535) NOT NULL,
ParamCurrencyID SMALLINT NOT NULL,
OpenstatServiceName VARCHAR(65535) NOT NULL,
OpenstatCampaignID VARCHAR(65535) NOT NULL,
OpenstatAdID VARCHAR(65535) NOT NULL,
OpenstatSourceID VARCHAR(65535) NOT NULL,
UTMSource VARCHAR(65535) NOT NULL,
UTMMedium VARCHAR(65535) NOT NULL,
UTMCampaign VARCHAR(65535) NOT NULL,
UTMContent VARCHAR(65535) NOT NULL,
UTMTerm VARCHAR(65535) NOT NULL,
FromTag VARCHAR(65535) NOT NULL,
HasGCLID SMALLINT NOT NULL,
RefererHash BIGINT NOT NULL,
URLHash BIGINT NOT NULL,
CLID INT NOT NULL
);
43 changes: 43 additions & 0 deletions presto/queries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
SELECT COUNT(*) FROM hits;
SELECT COUNT(*) FROM hits WHERE AdvEngineID <> 0;
SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits;
SELECT AVG(UserID) FROM hits;
SELECT COUNT(DISTINCT UserID) FROM hits;
SELECT COUNT(DISTINCT SearchPhrase) FROM hits;
SELECT MIN(EventDate), MAX(EventDate) FROM hits;
SELECT AdvEngineID, COUNT(*) FROM hits WHERE AdvEngineID <> 0 GROUP BY AdvEngineID ORDER BY COUNT(*) DESC;
SELECT RegionID, COUNT(DISTINCT UserID) AS u FROM hits GROUP BY RegionID ORDER BY u DESC LIMIT 10;
SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID) FROM hits GROUP BY RegionID ORDER BY c DESC LIMIT 10;
SELECT MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel ORDER BY u DESC LIMIT 10;
SELECT MobilePhone, MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhone, MobilePhoneModel ORDER BY u DESC LIMIT 10;
SELECT SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY u DESC LIMIT 10;
SELECT SearchEngineID, SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT UserID, COUNT(*) FROM hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10;
SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;
SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10;
SELECT UserID, extract(minute FROM EventTime), SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, extract(minute FROM EventTime), SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;
SELECT UserID FROM hits WHERE UserID = 435090932899640449;
SELECT COUNT(*) FROM hits WHERE URL LIKE '%google%';
SELECT SearchPhrase, MIN(URL), COUNT(*) AS c FROM hits WHERE URL LIKE '%google%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT SearchPhrase, MIN(URL), MIN(Title), COUNT(*) AS c, COUNT(DISTINCT UserID) FROM hits WHERE Title LIKE '%Google%' AND URL NOT LIKE '%.google.%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT * FROM hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10;
SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10;
SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10;
SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10;
SELECT CounterID, AVG(length(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\\1') HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(ResolutionWidth + 18), SUM(ResolutionWidth + 19), SUM(ResolutionWidth + 20), SUM(ResolutionWidth + 21), SUM(ResolutionWidth + 22), SUM(ResolutionWidth + 23), SUM(ResolutionWidth + 24), SUM(ResolutionWidth + 25), SUM(ResolutionWidth + 26), SUM(ResolutionWidth + 27), SUM(ResolutionWidth + 28), SUM(ResolutionWidth + 29), SUM(ResolutionWidth + 30), SUM(ResolutionWidth + 31), SUM(ResolutionWidth + 32), SUM(ResolutionWidth + 33), SUM(ResolutionWidth + 34), SUM(ResolutionWidth + 35), SUM(ResolutionWidth + 36), SUM(ResolutionWidth + 37), SUM(ResolutionWidth + 38), SUM(ResolutionWidth + 39), SUM(ResolutionWidth + 40), SUM(ResolutionWidth + 41), SUM(ResolutionWidth + 42), SUM(ResolutionWidth + 43), SUM(ResolutionWidth + 44), SUM(ResolutionWidth + 45), SUM(ResolutionWidth + 46), SUM(ResolutionWidth + 47), SUM(ResolutionWidth + 48), SUM(ResolutionWidth + 49), SUM(ResolutionWidth + 50), SUM(ResolutionWidth + 51), SUM(ResolutionWidth + 52), SUM(ResolutionWidth + 53), SUM(ResolutionWidth + 54), SUM(ResolutionWidth + 55), SUM(ResolutionWidth + 56), SUM(ResolutionWidth + 57), SUM(ResolutionWidth + 58), SUM(ResolutionWidth + 59), SUM(ResolutionWidth + 60), SUM(ResolutionWidth + 61), SUM(ResolutionWidth + 62), SUM(ResolutionWidth + 63), SUM(ResolutionWidth + 64), SUM(ResolutionWidth + 65), SUM(ResolutionWidth + 66), SUM(ResolutionWidth + 67), SUM(ResolutionWidth + 68), SUM(ResolutionWidth + 69), SUM(ResolutionWidth + 70), SUM(ResolutionWidth + 71), SUM(ResolutionWidth + 72), SUM(ResolutionWidth + 73), SUM(ResolutionWidth + 74), SUM(ResolutionWidth + 75), SUM(ResolutionWidth + 76), SUM(ResolutionWidth + 77), SUM(ResolutionWidth + 78), SUM(ResolutionWidth + 79), SUM(ResolutionWidth + 80), SUM(ResolutionWidth + 81), SUM(ResolutionWidth + 82), SUM(ResolutionWidth + 83), SUM(ResolutionWidth + 84), SUM(ResolutionWidth + 85), SUM(ResolutionWidth + 86), SUM(ResolutionWidth + 87), SUM(ResolutionWidth + 88), SUM(ResolutionWidth + 89) FROM hits;
SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10;
SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;
SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;
SELECT URL, COUNT(*) AS c FROM hits GROUP BY URL ORDER BY c DESC LIMIT 10;
SELECT 1, URL, COUNT(*) AS c FROM hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10;
SELECT ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3, COUNT(*) AS c FROM hits GROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3 ORDER BY c DESC LIMIT 10;
SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND DontCountHits = 0 AND IsRefresh = 0 AND URL <> '' GROUP BY URL ORDER BY PageViews DESC LIMIT 10;
SELECT Title, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title ORDER BY PageViews DESC LIMIT 10;
SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 AND IsLink <> 0 AND IsDownload = 0 GROUP BY URL ORDER BY PageViews DESC OFFSET 1000 LIMIT 10;
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 >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END, URL ORDER BY PageViews DESC OFFSET 1000 LIMIT 10;
SELECT URLHash, EventDate, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 AND TraficSourceID IN (-1, 6) AND RefererHash = 3594120000172545465 GROUP BY URLHash, EventDate ORDER BY PageViews DESC OFFSET 100 LIMIT 10;
SELECT WindowClientWidth, WindowClientHeight, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 AND DontCountHits = 0 AND URLHash = 2868770270353813622 GROUP BY WindowClientWidth, WindowClientHeight ORDER BY PageViews DESC OFFSET 10000 LIMIT 10;
SELECT DATE_FORMAT(EventTime, '%Y-%m-%d %H:%i:00') AS M, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-14') AND EventDate <= DATE('2013-07-15') AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_FORMAT(EventTime, '%Y-%m-%d %H:%i:00') ORDER BY DATE_FORMAT(EventTime, '%Y-%m-%d %H:%i:00') OFFSET 1000 LIMIT 10;
54 changes: 54 additions & 0 deletions presto/results/r5.4xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"system": "Presto",
"date": "2024-05-29",
"machine": "r5.4xlarge",
"cluster_size": 8,
"tags": ["Java", "column-oriented", "analytical", "aws"],
"load_time": 0,
"data_size": 14779976446,
"result": [
[0.402341,0.14951,0.107155],
[0.865487,0.485257,0.449763],
[1.08203,0.582326,0.578284],
[0.903962,0.639918,0.323288],
[1.038797,0.583585,0.545404],
[1.743717,1.229381,0.83916],
[0.435739,0.369782,0.218763],
[0.465126,0.721039,0.462598],
[1.656187,1.494111,1.15386],
[2.26484,2.182731,2.15843],
[1.613815,0.862942,0.742684],
[0.86709,0.883782,0.927072],
[1.16082,0.895078,0.941215],
[1.598979,1.759072,1.707651],
[0.995013,1.041356,1.022605],
[1.006878,0.546081,0.547675],
[1.697766,1.561924,1.643762],
[1.584176,1.468025,1.542148],
[2.549345,1.837268,1.792735],
[1.145295,0.724914,0.772503],
[4.041169,2.178436,1.944694],
[1.914926,1.840498,1.810634],
[3.332607,2.360467,2.354433],
[16.975438,14.76662,14.693455],
[0.86101,0.872084,0.925221],
[0.724581,1.692928,2.356877],
[0.944508,0.901719,0.911748],
[2.019593,2.060255,1.918732],
[6.497533,5.79828,5.426521],
[4.74789,4.869418,5.262414],
[1.453415,1.323398,1.381095],
[2.206553,1.681973,1.482222],
[3.807869,3.670072,3.547302],
[3.077398,2.848014,2.775159],
[2.998571,2.806663,3.031418],
[1.175695,1.365279,1.179885],
[1.436026,1.408173,1.412845],
[0.988737,1.093128,0.917244],
[1.279827,1.210123,1.225414],
[2.491988,2.587187,2.417893],
[1.147617,0.949788,0.825057],
[0.941498,0.845771,0.796313],
[0.935166,0.912135,0.964027]
]
}
54 changes: 54 additions & 0 deletions presto/results/r5.8xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"system": "Presto",
"date": "2024-05-28",
"machine": "r5.8xlarge",
"cluster_size": 16,
"tags": ["Java", "column-oriented", "analytical", "aws"],
"load_time": 0,
"data_size": 14779976446,
"result": [
[0.272035,0.099357,0.095395],
[1.030367,0.42591,0.317257],
[0.984987,0.566008,0.600528],
[1.101233,0.493982,0.310671],
[0.836894,0.551534,0.374873],
[1.122529,0.687931,0.677321],
[0.517202,0.221515,0.203558],
[0.337413,0.410747,0.432223],
[1.014921,0.906677,0.973607],
[1.676214,1.227126,1.282348],
[0.691311,0.586472,0.607044],
[0.758122,0.744563,0.756044],
[0.82537,0.782558,0.725295],
[1.132906,1.090836,1.231984],
[0.774198,0.757493,0.926341],
[0.750924,0.919412,0.425668],
[1.042794,1.081188,1.121617],
[0.977894,1.103013,1.936754],
[2.003017,1.40578,1.46733],
[0.966183,0.618001,0.622388],
[4.699365,1.885068,1.878264],
[1.699708,1.7211,1.782673],
[3.645092,2.153739,2.197017],
[18.776412,14.377456,13.632139],
[0.901729,0.722576,0.776895],
[0.673601,0.528899,0.592662],
[0.706932,1.111863,0.887926],
[1.864925,1.843051,2.01332],
[5.212292,4.749804,4.849626],
[4.017339,3.97698,3.797817],
[1.574938,1.249199,1.113597],
[2.108874,1.30992,1.301631],
[2.507421,2.557384,2.607363],
[2.783502,2.155876,2.391084],
[2.150036,2.168119,2.484738],
[0.91182,0.944813,0.840529],
[1.84562,1.463736,1.434443],
[0.940396,1.105479,0.981559],
[1.292506,1.326009,1.438981],
[2.678968,2.712577,2.823577],
[1.243846,0.958157,0.872599],
[0.834459,0.95686,0.886505],
[1.043745,0.970481,1.01311]
]
}
13 changes: 13 additions & 0 deletions presto/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

TRIES=3

queryNum=1
cat queries.sql | while read query; do
for i in $(seq 1 $TRIES); do
echo "Running query $queryNum: $query"
/opt/presto-cli --server 127.0.0.1:8080 --user clickbench_runner --catalog "hive" --schema "clickbench_parquet" --session offset_clause_enabled=true --execute "${query}"
execution_time=$(/opt/presto-cli --server 127.0.0.1:8080 --user clickbench_manager --execute "SELECT date_diff('millisecond',started,\"end\") FROM system.runtime.queries WHERE user='clickbench_runner' ORDER BY created DESC LIMIT 1" | tr -d '"') && echo "Execution time: ${execution_time}ms"
done
((queryNum++))
done

0 comments on commit dbc330c

Please sign in to comment.