Spark连接到MySQL并执行查询为啥速度会快
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spark连接到MySQL并执行查询为啥速度会快相关的知识,希望对你有一定的参考价值。
参考技术A mysql>select
min(yearD),
max(yearD)
as
max_year, Carrier, count(*)
as
cnt, sum(if(ArrDelayMinutes>30,
1, 0)) as
flights_delayed, round(sum(if(ArrDelayMinutes>30,
1, 0))/count(*),2)
as
rate FROM
ontime_part WHERE
DayOfWeek not
in
(6,7) and
OriginState not
in
('AK',
'HI',
'PR',
'VI')
and
DestState not
in
('AK',
'HI',
'PR',
'VI')
GROUP
by
carrier HAVING
cnt > 1000 and
max_year > '1990'
ORDER
by
rate DESC,
cnt desc
LIMIT 10;
+------------+----------+---------+----------+-----------------+------+
|
min(yearD)
| max_year | Carrier | cnt | flights_delayed | rate |
+------------+----------+---------+----------+-----------------+------+
|
2003 | 2013 | EV | 2962008 | 464264 | 0.16 |
|
2003 | 2013 | B6 | 1237400 | 187863 | 0.15 |
|
2006 | 2011 | XE | 1615266 | 230977 | 0.14 |
|
2003 | 2005 | DH | 501056 | 69833 | 0.14 |
|
2001 | 2013 | MQ | 4518106 | 605698 | 0.13 |
|
2003 | 2013 | FL | 1692887 | 212069 | 0.13 |
|
2004 | 2010 | OH | 1307404 | 175258 | 0.13 |
|
2006 | 2013 | YV | 1121025 | 143597 | 0.13 |
|
2003 | 2006 | RU | 1007248 | 126733 | 0.13 |
|
1988 | 2013 | UA | 10717383 | 1327196 | 0.12 |
+------------+----------+---------+----------+-----------------+------+
10
rows
in
set
(19 min
16.58 sec)本回答被提问者采纳
以上是关于Spark连接到MySQL并执行查询为啥速度会快的主要内容,如果未能解决你的问题,请参考以下文章
为啥我可以将 java 应用程序连接到 MySQL DB 但无法执行查询? [复制]
如何使用 java 连接到 spark-shell 并执行 hive 查询
将 Grafana 连接到 MySQL 显示查询失败,为啥?