相关动态
hive查询where join_hive left join on 条件与where条件效率优化
2025-01-02 17:07

参考网址:http://shiyanjun.cn/archives/588.html

在hive执行sql过程中,一条sql执行了一个多小时,检查sql发现,在left

join之后,on只使用了关联字段,而其他筛选条件都在where之中使用。经过修改后,将where字段放在on

条件中进行判断,执行效率提高到半小时之内结束。在on条件中使用条件,可以发现筛选分区后再进行关联操作,splits只有12个

INFO  : number of splits:12

,而where中使用条件,则是关联之后再进行分区筛选,分片数达到了94个splits,而且需要执行94个map,412个reduce,消耗的资源是非常巨大的。

INFO : number of splits:94​

原始hql

优化后hql:​

查看执行计划发现,on中使用分区字段过滤,则执行计划中在scan表的时候就已经过滤掉分区了,而如果在where条件中过滤,则不会在scan中过滤,输入数据量巨大

------------------------------------执行过程日志如下

INFO  : Query ID =

hive_20171026031919_9b1b59f2-b867-466a-95a5-06b5be6daafa

INFO  : Total jobs = 5

INFO  : Starting task [Stage-12:MAPREDLOCAL] in

serial mode

INFO  : Execution completed successfully

INFO  : MapredLocal task succeeded

INFO  : Launching Job 1 out of 5

INFO  : Starting task [Stage-10:MAPRED] in

serial mode

INFO  : Number of reduce tasks is set to 0

since there's no reduce operator

INFO  : number of splits:12

INFO  : Submitting tokens for job:

job_1508725411753_0155

INFO  : Kind: HDFS_DELEGATION_TOKEN, Service:

10.1.2.94:8020, Ident: (HDFS_DELEGATION_TOKEN token 999 for

hive)

INFO  : The url to track the job:

http://host:8088/proxy/application_1508725411753_0155/

INFO  : Starting Job = job_1508725411753_0155,

Tracking URL =

http://host:8088/proxy/application_1508725411753_0155/

INFO  : Kill Command =

/opt/cloudera/parcels/CDH-5.8.0-1.cdh5.8.0.p0.42/lib/hadoop/bin/hadoop

job  -kill job_1508725411753_0155

INFO  : Hadoop job information for Stage-10:

number of mappers: 12; number of reducers: 0

.........​

INFO  : 2017-10-26 03:21:44,169

Stage-10 map = 100%,  reduce = 0%, Cumulative CPU

176.25 sec

INFO  : MapReduce Total cumulative CPU time: 2

minutes 56 seconds 250 msec

INFO  : Ended Job = job_1508725411753_0155

INFO  : Starting task [Stage-9:CONDITIONAL] in

serial mode

INFO  : Stage-11 is filtered out by condition

resolver.

INFO  : Stage-2 is selected by condition

resolver.

INFO  : Launching Job 2 out of 5

INFO  : Starting task [Stage-2:MAPRED] in

serial mode

INFO  : Number of reduce tasks not specified.

Estimated from input data size: 12

INFO  : In order to change the average load for

a reducer (in bytes):

INFO  :   set

hive.exec.reducers.bytes.per.reducer=

INFO  : In order to limit the maximum number of

reducers:

INFO  :   set

hive.exec.reducers.max=

INFO  : In order to set a constant number of

reducers:

INFO  :   set

mapreduce.job.reduces=

INFO  : number of splits:4

INFO  : Submitting tokens for job:

job_1508725411753_0156

INFO  : Kind: HDFS_DELEGATION_TOKEN, Service:

10.1.2.94:8020, Ident: (HDFS_DELEGATION_TOKEN token 1000 for

hive)

INFO  : The url to track the job:

http://host:8088/proxy/application_1508725411753_0156/

INFO  : Starting Job = job_1508725411753_0156,

Tracking URL =

http://host:8088/proxy/application_1508725411753_0156/

INFO  : Kill Command =

/opt/cloudera/parcels/CDH-5.8.0-1.cdh5.8.0.p0.42/lib/hadoop/bin/hadoop

job  -kill job_1508725411753_0156

INFO  : Hadoop job information for Stage-2:

number of mappers: 4; number of reducers: 12

INFO  : 2017-10-26 03:21:56,128 Stage-2 map =

0%,  reduce = 0%

.........​

INFO  : 2017-10-26 03:27:43,452

Stage-2 map = 100%,  reduce = 100%, Cumulative CPU

981.83 sec

INFO  : MapReduce Total cumulative CPU time: 16

minutes 21 seconds 830 msec

INFO  : Ended Job = job_1508725411753_0156

INFO  : Launching Job 3 out of 5

INFO  : Starting task [Stage-3:MAPRED] in

serial mode

INFO  : Number of reduce tasks not specified.

Estimated from input data size: 1

INFO  : In order to change the average load for

a reducer (in bytes):

INFO  :   set

hive.exec.reducers.bytes.per.reducer=

INFO  : In order to limit the maximum number of

reducers:

INFO  :   set

hive.exec.reducers.max=

INFO  : In order to set a constant number of

reducers:

INFO  :   set

mapreduce.job.reduces=

INFO  : number of splits:1

INFO  : Submitting tokens for job:

job_1508725411753_0158

INFO  : Kind: HDFS_DELEGATION_TOKEN, Service:

10.1.2.94:8020, Ident: (HDFS_DELEGATION_TOKEN token 1002 for

hive)

INFO  : The url to track the job:

http://host:8088/proxy/application_1508725411753_0158/

INFO  : Starting Job = job_1508725411753_0158,

Tracking URL =

http://host:8088/proxy/application_1508725411753_0158/

INFO  : Kill Command =

/opt/cloudera/parcels/CDH-5.8.0-1.cdh5.8.0.p0.42/lib/hadoop/bin/hadoop

job  -kill job_1508725411753_0158

INFO  : Hadoop job information for Stage-3:

number of mappers: 1; number of reducers: 1

INFO  : 2017-10-26 03:28:00,533 Stage-3 map =

0%,  reduce = 0%

INFO  : 2017-10-26 03:28:13,143 Stage-3 map =

100%,  reduce = 0%, Cumulative CPU 6.57 sec

INFO  : 2017-10-26 03:28:28,700 Stage-3 map =

100%,  reduce = 100%, Cumulative CPU 15.46 sec

INFO  : MapReduce Total cumulative CPU time: 15

seconds 460 msec

INFO  : Ended Job = job_1508725411753_0158

INFO  : Launching Job 4 out of 5

INFO  : Starting task [Stage-4:MAPRED] in

serial mode

INFO  : Number of reduce tasks determined at

compile time: 1

INFO  : In order to change the average load for

a reducer (in bytes):

INFO  :   set

hive.exec.reducers.bytes.per.reducer=

INFO  : In order to limit the maximum number of

reducers:

INFO  :   set

hive.exec.reducers.max=

INFO  : In order to set a constant number of

reducers:

INFO  :   set

mapreduce.job.reduces=

INFO  : number of splits:1

INFO  : Submitting tokens for job:

job_1508725411753_0159

INFO  : Kind: HDFS_DELEGATION_TOKEN, Service:

10.1.2.94:8020, Ident: (HDFS_DELEGATION_TOKEN token 1004 for

hive)

INFO  : The url to track the job:

http://host:8088/proxy/application_1508725411753_0159/

INFO  : Starting Job = job_1508725411753_0159,

Tracking URL =

http://host:8088/proxy/application_1508725411753_0159/

INFO  : Kill Command =

/opt/cloudera/parcels/CDH-5.8.0-1.cdh5.8.0.p0.42/lib/hadoop/bin/hadoop

job  -kill job_1508725411753_0159

INFO  : Hadoop job information for Stage-4:

number of mappers: 1; number of reducers: 1

INFO  : 2017-10-26 03:28:42,569 Stage-4 map =

0%,  reduce = 0%

INFO  : 2017-10-26 03:28:56,012 Stage-4 map =

100%,  reduce = 0%, Cumulative CPU 7.64 sec

INFO  : 2017-10-26 03:29:09,498 Stage-4 map =

100%,  reduce = 100%, Cumulative CPU 13.13 sec

INFO  : MapReduce Total cumulative CPU time: 13

seconds 130 msec

INFO  : Ended Job = job_1508725411753_0159

INFO  : Starting task [Stage-0:MOVE] in serial

mode

INFO  : Loading data to table otl.oel_test from

hdfs://test94.eformax.com:8020/user/hive/warehouse/otl.db/oel_test/.hive-staging_hive_2017-10-26_03-19-40_941_4069260026444954348-5/-ext-10000

INFO  : Starting task [Stage-5:STATS] in serial

mode

INFO  : Table otl.oel_test stats: [numFiles=1,

numRows=188992, totalSize=15418476, rawDataSize=15229484]

INFO  : MapReduce Jobs

Launched:

INFO  : Stage-Stage-10: Map:

12   Cumulative CPU: 176.25

sec   HDFS Read: 3308304990 HDFS

Write: 500780832 SUCCESS

INFO  : Stage-Stage-2: Map: 4

Reduce: 12   Cumulative CPU:

981.83 sec   HDFS Read: 802041177

HDFS Write: 15495161 SUCCESS

INFO  : Stage-Stage-3: Map: 1

Reduce: 1   Cumulative CPU: 15.46

sec   HDFS Read: 15527532 HDFS

Write: 17183487 SUCCESS

INFO  : Stage-Stage-4: Map: 1

Reduce: 1   Cumulative CPU: 13.13

sec   HDFS Read: 17193170 HDFS

Write: 15418554 SUCCESS

INFO  : Total MapReduce CPU Time Spent: 19

minutes 46 seconds 670 msec

INFO  : Completed executing

command(queryId=hive_20171026031919_9b1b59f2-b867-466a-95a5-06b5be6daafa);

Time taken: 565.401 seconds

INFO  : OK

    以上就是本篇文章【hive查询where join_hive left join on 条件与where条件效率优化】的全部内容了,欢迎阅览 ! 文章地址:http://sjzytwl.xhstdz.com/news/12878.html 
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 物流园资讯移动站 http://sjzytwl.xhstdz.com/mobile/ , 查看更多   
最新文章
选对的很重要,2024年旗舰爆品手机选购指南手机怎么选「选对的很重要,2024年旗舰爆品手机选购指南」
时间过的真快,感觉刚刚迈入2024年,转眼前已经临近2024年的中旬了,而相对于如今的市场来讲,各手机厂家更是纷纷打出了不同的“
转载丨稻盛和夫:全员参与经营,人人都是经营者手机搜狐网「转载丨稻盛和夫:全员参与经营,人人都是经营者」
“既然社长都这么说了,那我们也应该努力,一起为企业经营出谋划策。”员工一旦具有这样的心态,就等于是对企业经营倾注了意识。
车载手机支架怎么选?看看这十大品牌,稳固又实用车载手机支架「车载手机支架怎么选?看看这十大品牌,稳固又实用」
不管是新手司机还是老司机,车载手机支架是行车路上必不可少的工具。不仅要抱紧手机,还要牢牢地固定在控制台上,不受复杂路况的
第五代“江姐”扮演者王莉与红色传承的十年情结手机搜狐网「第五代“江姐”扮演者王莉与红色传承的十年情结」
为传承红色经典,中国人民解放军空军政治部文工团大型民族歌剧《江姐》全国巡演再次启程。《江姐》于11月18日至11月29日,陆续在清
steam手机客户端steam手机版下载「steam手机客户端」
steam是一款很专业的游戏平台,steam为你提供丰富的游戏资讯信息,在这里用户可以查看超多游戏的动态,超多最新最热的游戏资讯在
寻仙万象宝盘全攻略手机搜狐网「寻仙万象宝盘全攻略」
战力提升之《万象宝盘》系统来了,本文约5800字,图片约100张,阅读需要阅读15分钟。完整学习需要50分钟。提示:本篇万象宝盘系
如何辨别蛋白粉真假手机搜狐网「如何辨别蛋白粉真假」
在北上广深等一线城市,毫不夸张地说,一百米一个健身房!就拿小编的健身房为例,晚上七点之后,完全人满为患,导致小编每每要下
更换手机时,教你一键把旧手机资料导入到新手机,简单又实用旧手机如何导入新手机「更换手机时,教你一键把旧手机资料导入到新手机,简单又实用」
点击上方蓝色字关注我们~我们的手机刚刚买回来的时候,里边是什么东西都没有,一些重要的资料,都会在我们的旧手机里边,要想把
如何选择适合自己的手机?拯救你的科技生活!手机「如何选择适合自己的手机?拯救你的科技生活!」
在现代生活中,手机几乎已经成为了人们不可或缺的工具。从通讯、社交到娱乐和工作,智能手机以其多功能性影响着我们的日常。然而
“5G 太耗电,关掉它!”关闭手机「“5G 太耗电,关掉它!”」
作者 | Carol出品 | CSDN(ID:CSDNnews)随着5G的普及,如今已经有很多手机用户已经体验到了5G的便捷
相关文章