Benchmarking ClickHouse on my MacBook Pro

I have used data from BUREAU OF TRANSPORTATION STATISTICS https://www.transtats.bts.gov  for benchmarking ClickHouse (https://clickhouse.yandex)

From their website, here is what the OnTime data covers:

Airline on-time data are reported each month to the U.S. Department of Transportation (DOT), Bureau of Transportation Statistics (BTS) by the 16 U.S. air carriers that have at least 1 percent of total domestic scheduled-service passenger revenues, plus two other carriers that report voluntarily. The data cover nonstop scheduled-service flights between points within the United States (including territories) as described in 14 CFR Part 234 of DOT’s regulations. Data are available since January 1995. The following statistics are available:

Summary Statistics – All and late flights (total number, average departure delay, average taxi-out and average scheduled departure) and late flights (total and percent of diverted and cancelled flights).

Origin Airport
Destination Airport
Origin and Destination Airport
Airline
Flight Number

Detailed Statistics – Departure and arrival statistics (scheduled departure time, actual departure time, scheduled elapse time, departure delay, wheels-off time and taxi-out time) by airport and airline; airborne time, cancellation and diversion by airport and airline.

Departures
Arrivals
Airborne Time
Cancellation
Diversion

Downloading the data

Data is actually available from October 1987 until today (they are a few months behind in entering the latest data). Their drop-down in their website ( https://www.transtats.bts.gov) however only goes back to 1995. Data comes in a .zip file for every month, so I downloaded few files. Here is the direct link to download the files:

root@CSQL:/home/shiv# wget http://www.transtats.bts.gov/Download/On_Time_On_Time_Performance_2013_5.zip

URL transformed to HTTPS due to an HSTS policy

--2018-01-23 18:01:08--  https://www.transtats.bts.gov/Download/On_Time_On_Time_Performance_2013_5.zip

Resolving www.transtats.bts.gov (www.transtats.bts.gov)... 204.68.194.70

Connecting to www.transtats.bts.gov (www.transtats.bts.gov)|204.68.194.70|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 26562728 (25M) [application/x-zip-compressed]

Saving to: 'On_Time_On_Time_Performance_2013_5.zip'

On_Time_On_Time_Performance_201 100%[=======================================================>]  25.33M   207KB/s    in 2m 16s

2018-01-23 18:03:25 (191 KB/s) - 'On_Time_On_Time_Performance_2013_5.zip' saved [26562728/26562728]

 “ontime” table structure

desc ontime

DESCRIBE TABLE ontime

┌─name─────────────────┬─type───────────┬─default_type─┬─default_expression─┐

│ Year                 │ UInt16         │              │                    │

│ Quarter              │ UInt8          │              │                    │

│ Month                │ UInt8          │              │                    │

│ DayofMonth           │ UInt8          │              │                    │

│ DayOfWeek            │ UInt8          │              │                    │

│ FlightDate           │ Date           │              │                    │

│ UniqueCarrier        │ FixedString(7) │              │                    │

│ AirlineID            │ Int32          │              │                    │

│ Carrier              │ FixedString(2) │              │                    │

│ TailNum              │ String         │              │                    │

│ FlightNum            │ String         │              │                    │

│ OriginAirportID      │ Int32          │              │                    │

│ OriginAirportSeqID   │ Int32          │              │                    │

│ OriginCityMarketID   │ Int32          │              │                    │

│ Origin               │ FixedString(5) │              │                    │

│ OriginCityName       │ String         │              │                    │

│ OriginState          │ FixedString(2) │              │                    │

│ OriginStateFips      │ String         │              │                    │

│ OriginStateName      │ String         │              │                    │

│ OriginWac            │ Int32          │              │                    │

│ DestAirportID        │ Int32          │              │                    │

│ DestAirportSeqID     │ Int32          │              │                    │

│ DestCityMarketID     │ Int32          │              │                    │

│ Dest                 │ FixedString(5) │              │                    │

│ DestCityName         │ String         │              │                    │

│ DestState            │ FixedString(2) │              │                    │

│ DestStateFips        │ String         │              │                    │

│ DestStateName        │ String         │              │                    │

│ DestWac              │ Int32          │              │                    │

│ CRSDepTime           │ Int32          │              │                    │

│ DepTime              │ Int32          │              │                    │

│ DepDelay             │ Int32          │              │                    │

│ DepDelayMinutes      │ Int32          │              │                    │

│ DepDel15             │ Int32          │              │                    │

│ DepartureDelayGroups │ String         │              │                    │

│ DepTimeBlk           │ String         │              │                    │

│ TaxiOut              │ Int32          │              │                    │

│ WheelsOff            │ Int32          │              │                    │

│ WheelsOn             │ Int32          │              │                    │

│ TaxiIn               │ Int32          │              │                    │

│ CRSArrTime           │ Int32          │              │                    │

│ ArrTime              │ Int32          │              │                    │

│ ArrDelay             │ Int32          │              │                    │

│ ArrDelayMinutes      │ Int32          │              │                    │

│ ArrDel15             │ Int32          │              │                    │

│ ArrivalDelayGroups   │ Int32          │              │                    │

│ ArrTimeBlk           │ String         │              │                    │

│ Cancelled            │ UInt8          │              │                    │

│ CancellationCode     │ FixedString(1) │              │                    │

│ Diverted             │ UInt8          │              │                    │

│ CRSElapsedTime       │ Int32          │              │                    │

│ ActualElapsedTime    │ Int32          │              │                    │

│ AirTime              │ Int32          │              │                    │

│ Flights              │ Int32          │              │                    │

│ Distance             │ Int32          │              │                    │

│ DistanceGroup        │ UInt8          │              │                    │

│ CarrierDelay         │ Int32          │              │                    │

│ WeatherDelay         │ Int32          │              │                    │

│ NASDelay             │ Int32          │              │                    │

│ SecurityDelay        │ Int32          │              │                    │

│ LateAircraftDelay    │ Int32          │              │                    │

│ FirstDepTime         │ String         │              │                    │

│ TotalAddGTime        │ String         │              │                    │

│ LongestAddGTime      │ String         │              │                    │

│ DivAirportLandings   │ String         │              │                    │

│ DivReachedDest       │ String         │              │                    │

│ DivActualElapsedTime │ String         │              │                    │

│ DivArrDelay          │ String         │              │                    │

│ DivDistance          │ String         │              │                    │

│ Div1Airport          │ String         │              │                    │

│ Div1AirportID        │ Int32          │              │                    │

│ Div1AirportSeqID     │ Int32          │              │                    │

│ Div1WheelsOn         │ String         │              │                    │

│ Div1TotalGTime       │ String         │              │                    │

│ Div1LongestGTime     │ String         │              │                    │

│ Div1WheelsOff        │ String         │              │                    │

│ Div1TailNum          │ String         │              │                    │

│ Div2Airport          │ String         │              │                    │

│ Div2AirportID        │ Int32          │              │                    │

│ Div2AirportSeqID     │ Int32          │              │                    │

│ Div2WheelsOn         │ String         │              │                    │

│ Div2TotalGTime       │ String         │              │                    │

│ Div2LongestGTime     │ String         │              │                    │

│ Div2WheelsOff        │ String         │              │                    │

│ Div2TailNum          │ String         │              │                    │

│ Div3Airport          │ String         │              │                    │

│ Div3AirportID        │ Int32          │              │                    │

│ Div3AirportSeqID     │ Int32          │              │                    │

│ Div3WheelsOn         │ String         │              │                    │

│ Div3TotalGTime       │ String         │              │                    │

│ Div3LongestGTime     │ String         │              │                    │

│ Div3WheelsOff        │ String         │              │                    │

│ Div3TailNum          │ String         │              │                    │

│ Div4Airport          │ String         │              │                    │

│ Div4AirportID        │ Int32          │              │                    │

│ Div4AirportSeqID     │ Int32          │              │                    │

│ Div4WheelsOn         │ String         │              │                    │

│ Div4TotalGTime       │ String         │              │                    │

│ Div4LongestGTime     │ String         │              │                    │

│ Div4WheelsOff        │ String         │              │                    │

│ Div4TailNum          │ String         │              │                    │

│ Div5Airport          │ String         │              │                    │

│ Div5AirportID        │ Int32          │              │                    │

│ Div5AirportSeqID     │ Int32          │              │                    │

│ Div5WheelsOn         │ String         │              │                    │

│ Div5TotalGTime       │ String         │              │                    │

│ Div5LongestGTime     │ String         │              │                    │

│ Div5WheelsOff        │ String         │              │                    │

│ Div5TailNum          │ String         │              │                    │

└──────────────────────┴────────────────┴──────────────┴────────────────────┘

109 rows in set. Elapsed: 0.091 sec.

Load data to ClickHouse

root@CSQL:/home/shiv# for i in On_Time_On_Time_Performance_2013_5.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --query="INSERT INTO ontime FORMAT CSVWithNames"; done

I have loaded 2.5 million records only for this benchmarking (doing this on my MacBook VM)

select count(1) from ontime;

SELECT count(1)

FROM ontime

┌─count(1)─┐

│  2530089 │

└──────────┘

Query performance

Query 1

select avg(c1) from (select Year, Month, count(*) as c1 from ontime group by Year, Month);

SELECT avg(c1)

FROM

(

SELECT

Year,

Month,

count(*) AS c1

FROM ontime

GROUP BY

Year,

Month

)

┌──avg(c1)─┐

│ 506017.8 │

└──────────┘

1 rows in set. Elapsed: 0.094 sec. Processed 2.53 million rows, 7.59 MB (26.86 million rows/s., 80.57 MB/s.)

Query 2

The number of flights per day from the year 1980 to 2008

SELECT

DayOfWeek,

count(*) AS c

FROM ontime

WHERE (Year >= 1980) AND (Year <= 2013)

GROUP BY DayOfWeek

ORDER BY c DESC

┌─DayOfWeek─┬──────c─┐

│         3 │ 384020 │

│         5 │ 381632 │

│         1 │ 368063 │

│         4 │ 365107 │

│         2 │ 363124 │

│         7 │ 362386 │

│         6 │ 305757 │

└───────────┴────────┘

7 rows in set. Elapsed: 0.035 sec. Processed 2.53 million rows, 7.59 MB (71.33 million rows/s., 213.99 MB/s.)

Query 3

The number of flights delayed by more than 10 minutes, grouped by the day of the week, for 1980-2014

SELECT

DayOfWeek,

count(*) AS c

FROM ontime

WHERE (DepDelay > 10) AND (Year >= 1980) AND (Year <= 2014)

GROUP BY DayOfWeek

ORDER BY c DESC

┌─DayOfWeek─┬─────c─┐

│         5 │ 82774 │

│         1 │ 80595 │

│         3 │ 78867 │

│         4 │ 78455 │

│         2 │ 73523 │

│         7 │ 72340 │

│         6 │ 54453 │

└───────────┴───────┘

7 rows in set. Elapsed: 0.098 sec. Processed 2.53 million rows, 17.71 MB (25.79 million rows/s., 180.53 MB/s.)

Query 4

The number of delays by airport for 2000-2008

SELECT

Origin,

count(*) AS c

FROM ontime

WHERE (DepDelay > 10) AND (Year >= 1980) AND (Year <= 2014)

GROUP BY Origin

ORDER BY c DESC

LIMIT 10

┌─Origin──┬─────c─┐

│ ATL\0\0 │ 35945 │

│ ORD\0\0 │ 32616 │

│ DFW\0\0 │ 27470 │

│ DEN\0\0 │ 21119 │

│ LAX\0\0 │ 15454 │

│ IAH\0\0 │ 14651 │

│ DTW\0\0 │ 14040 │

│ SFO\0\0 │ 14018 │

│ EWR\0\0 │ 12524 │

│ PHX\0\0 │ 11718 │

└─────────┴───────┘

10 rows in set. Elapsed: 0.087 sec. Processed 2.53 million rows, 27.83 MB (29.07 million rows/s., 319.73 MB/s.)

Query 5

The number of delays by carrier between 1980 – 2014

SELECT

Carrier,

c,

c2,

(c * 1000) / c2 AS c3

FROM

(

SELECT

Carrier,

count(*) AS c

FROM ontime

WHERE (DepDelay > 10) AND (Year >= 1980) AND (Year <= 2014)

GROUP BY Carrier

)

ANY INNER JOIN

(

SELECT

Carrier,

count(*) AS c2

FROM ontime

WHERE (Year >= 1980) AND (Year <= 2014)

GROUP BY Carrier

) USING (Carrier)

ORDER BY c3 DESC

┌─Carrier─┬─────c─┬─────c2─┬─────────────────c3─┐

│ PI      │ 12334 │  39594 │  311.5118452290751 │

│ EA      │ 10679 │  37632 │ 283.77444727891157 │

│ TW      │  6573 │  23761 │ 276.62977147426454 │

│ WN      │ 91808 │ 388242 │ 236.47106701490307 │

│ MQ      │ 33623 │ 143640 │ 234.07825118351434 │

│ EV      │ 32068 │ 140110 │  228.8773106844622 │

│ VX      │  1166 │   5128 │ 227.37909516380654 │

│ CO      │ 21934 │  98702 │ 222.22447366821342 │

│ F9      │  5790 │  26656 │ 217.21188475390156 │

│ AL      │  6634 │  31663 │ 209.51899693648738 │

│ DL      │ 58111 │ 277642 │ 209.30190677203018 │

│ OH      │  6888 │  33223 │ 207.32624988712638 │

│ UA      │ 36478 │ 176851 │ 206.26403017229194 │

│ FL      │ 15847 │  76950 │ 205.93892137751786 │

│ AA      │ 47797 │ 232915 │ 205.21220187622094 │

│ B6      │ 13743 │  67330 │ 204.11406505272538 │

│ NW      │ 11219 │  55516 │ 202.08588515022697 │

│ XE      │ 17577 │  87277 │  201.3932651213951 │

│ 9E      │ 16419 │  89637 │ 183.17212758124435 │

│ PA      │  1079 │   6080 │  177.4671052631579 │

│ PS      │  2306 │  13169 │ 175.10820867188093 │

│ OO      │ 33745 │ 193333 │ 174.54340438517997 │

│ YV      │ 10380 │  60881 │ 170.49654243524253 │

│ US      │ 17427 │ 132937 │ 131.09217147972348 │

│ HP      │  2024 │  15583 │ 129.88513123275365 │

│ AS      │  5824 │  52993 │ 109.90130771988753 │

│ HA      │  1534 │  22644 │  67.74421480303833 │

└─────────┴───────┴────────┴────────────────────┘

27 rows in set. Elapsed: 0.154 sec. Processed 5.06 million rows, 30.36 MB (32.95 million rows/s., 197.70 MB/s.)

Query 6

Percentage of flights delayed for more than 10 minutes, by year

SELECT 

    Year, 

    c1 / c2

FROM 

(

    SELECT 

        Year, 

        count(*) * 1000 AS c1

    FROM ontime 

    WHERE DepDelay > 10

    GROUP BY Year

) 

ANY INNER JOIN 

(

    SELECT 

        Year, 

        count(*) AS c2

    FROM ontime 

    GROUP BY Year

) USING (Year)

ORDER BY Year ASC

┌─Year─┬─────divide(c1, c2)─┐

│ 1988 │ 233.08158828241218 │

│ 2009 │ 126.58476272716568 │

│ 2010 │ 227.19108136859793 │

│ 2013 │ 217.86337903405135 │

└──────┴────────────────────┘

4 rows in set. Elapsed: 0.074 sec. Processed 5.06 million rows, 20.24 MB (68.61 million rows/s., 274.44 MB/s.)

Conclusion

I am very impressed with performance of ClickHouse in my MacBook VM , These tests are conducted on cold cache and no tweaking is done to the ClickHouse Server for performance

About Shiv Iyer 36 Articles
WebScale Database Infrastructure Operations Expert in MySQL, MariaDB, PostgreSQL and ClickHouse with core interests in performance, scalability, high availability and database reliability engineering. Shiv currently is the Founder and Principal of MinervaDB, an independent and vendor neutral Consulting, 24*7 Support and Remote DBA Services provider for MySQL, MariaDB, PostgreSQL and ClickHouse serving approximately 300 customers globally.
UA-155183614-1