概述:
下載
導入
查詢驗證數據
運行腳本:
數據全部導入之後按照年份查詢數據:
總的行數:
Clickhouse> select count(1) from ontime;
SELECT count(1)
FROM ontime
┌──count(1)─┐
│ 193849243 │
└───────────┘
1 rows in set. Elapsed: 0.020 sec.
按照10年劃分統計:
Clickhouse> select cast(substring(cast(Year as String),1,3) as UInt8) as TY,count(1) from ontime group by TY order by 1 ;
SELECT
CAST(substring(CAST(Year, 'String'), 1, 3), 'UInt8') AS TY,
count(1)
FROM ontime
GROUP BY TY
ORDER BY 1 ASC
┌──TY─┬─count(1)─┐
│ 198 │ 11555122 │
│ 199 │ 52694390 │
│ 200 │ 65737983 │
│ 201 │ 62031901 │
│ 202 │ 1829847 │
└─────┴──────────┘
5 rows in set. Elapsed: 2.376 sec. Processed 193.85 million rows, 387.70 MB (81.59 million rows/s., 163.18 MB/s.)
按照年份:
Clickhouse> select Year,count(1) from ontime group by Year;
SELECT
Year,
count(1)
FROM ontime
GROUP BY Year
┌─Year─┬─count(1)─┐
│ 1987 │ 1311826 │
│ 1988 │ 5202096 │
│ 1989 │ 5041200 │
│ 1990 │ 5270893 │
│ 1991 │ 5076925 │
│ 1992 │ 5092157 │
│ 1993 │ 5070501 │
│ 1994 │ 5180048 │
│ 1995 │ 5327435 │
│ 1996 │ 5351983 │
│ 1997 │ 5411843 │
│ 1998 │ 5384721 │
│ 1999 │ 5527884 │
│ 2000 │ 5683047 │
│ 2001 │ 5967780 │
│ 2002 │ 5271359 │
│ 2003 │ 6488540 │
│ 2004 │ 7129270 │
│ 2005 │ 7140596 │
│ 2006 │ 7141922 │
│ 2007 │ 7455458 │
│ 2008 │ 7009726 │
│ 2009 │ 6450285 │
│ 2010 │ 6450117 │
│ 2011 │ 6085281 │
│ 2012 │ 6096762 │
│ 2013 │ 5833089 │
│ 2014 │ 5819811 │
│ 2015 │ 5819079 │
│ 2016 │ 5617658 │
│ 2017 │ 5674621 │
│ 2018 │ 7213446 │
│ 2019 │ 7422037 │
│ 2020 │ 1829847 │
└──────┴──────────┘
34 rows in set. Elapsed: 0.363 sec. Processed 193.85 million rows, 387.70 MB (534.25 million rows/s., 1.07 GB/s.)
參考:
https://clickhouse.tech/docs/en/getting-started/example-datasets/ontime/
https://github.com/Percona-Lab/ontime-airline-performance
https://nickmakos.blogspot.ru/2012/08/analyzing-air-traffic-performance-with.html