Hive union all性能优化

一、原SQL

*****  运行时间58min  ********

select  `time`,srcroot,srctag,terminal ,tokentype as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and tokentype<>'null'  and os_type<>'null' and  method='UserIntf.login' group by `time`,  srcroot, srctag,terminal ,tokentype  
-- union all select  `time`,srcroot,srctag,terminal ,"onekeyLogin" as type,count(1) as cnt from 
-- hdp_quc.ucent_login_rec_hive_part
-- where  `time` ="2022-01-03" and errno='0' and tokentype<>'null' and method='UserIntf.login' group by `time`,  srcroot, srctag,terminal
union all select  `time`,srcroot,srctag,terminal ,"smscode" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and smscode<>'null' and method='UserIntf.login' group by `time`,  srcroot, srctag,terminal
union all select  `time`,srcroot,srctag,terminal ,"weixinLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and platform='weixin' and (method='CommonAccount.oauthLogin' or method='CommonAccount.oauthLoginNew') group by `time`,  srcroot, srctag,terminal
union all select  `time`,srcroot,srctag,terminal ,"QQLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and platform='qq' and (method='CommonAccount.oauthLogin' or method='CommonAccount.oauthLoginNew') group by `time`,  srcroot, srctag,terminal
union all select  `time`,srcroot,srctag,terminal ,"accLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part where  `time` ="2022-01-03" and errno='0' and smscode='null' and srcroot<>'null' and tokentype='null' and platform='null' and method='UserIntf.login' group by `time`,  srcroot, srctag,terminal
union all select  `time`,srcroot,srctag,terminal ,"autoLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and method='CommentAccount.getUserInfo' group by `time`,  srcroot, srctag,terminal 

union all select  `time`,srcroot,srctag,terminal ,"weiboLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and platform='Sina' and (method='CommonAccount.oauthLogin' or method='CommonAccount.oauthLoginNew') group by `time`,  srcroot, srctag,terminal
union all select  `time`,srcroot,srctag,terminal ,"appleLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and platform='apple' and (method='CommonAccount.oauthLogin' or method='CommonAccount.oauthLoginNew') group by `time`,  srcroot, srctag,terminal 
union all select  `time`,srcroot,srctag,terminal ,"googleLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and platform='google' and (method='CommonAccount.oauthLogin' or method='CommonAccount.oauthLoginNew') group by `time`,  srcroot, srctag,terminal 
union all select  `time`,srcroot,srctag,terminal ,"facebookLogin" as type,count(1) as cnt from 
hdp_quc.ucent_login_rec_hive_part
where  `time` ="2022-01-03" and errno='0' and platform='facebook' and (method='CommonAccount.oauthLogin' or method='CommonAccount.oauthLoginNew') group by `time`,  srcroot, srctag,terminal ;

二、调优参数

1.set hive.exec.parallel=true;

设置为TRUE的时候,同一个SQL中可以并行执行的job会并发的执行。

2.set hive.exec.parallel.thread.number=32;

控制对于同一个SQL来说同时可以运行job的最大数,默认为8,此时可以同时运行8个job。

3.性能对比

优化前:58min
优化后:

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值