hive并行执行job

用过oracle rac的应该都知道parallel的用途。

并行执行的确可以大的加快任务的执行速率,但不会减少其占用的资源。

在hive中也有并行执行的选项。

 

 

set hive.exec.parallel=true;   //打开任务并行执行

 

set hive.exec.parallel.thread.number=16; //同一个sql允许最大并行度,默认为8。

 

对于同一个SQL产生的JOB,如果不存在依赖的情况下,将会并行启动JOB,

比如:

 

Sql代码   收藏代码
  1. from (  
  2. select phone,to_phone, substr(to_phone,-1) as key  
  3. from youni_contact4_lxw   
  4. where youni_id='1'   
  5. and length(to_phone) = 11   
  6. and  substr(to_phone,1,2) IN ('13','14','15','18')   
  7. group by phone,to_phone, substr(to_phone,-1)   
  8. ) t  
  9. insert overwrite table youni_contact41_lxw partition(pt='0')  
  10. select phone,to_phone where key='0'  
  11. insert overwrite table youni_contact41_lxw partition(pt='1')  
  12. select phone,to_phone where key='1'  
  13. insert overwrite table youni_contact41_lxw partition(pt='2')  
  14. select phone,to_phone where key='2'  
  15. insert overwrite table youni_contact41_lxw partition(pt='3')  
  16. select phone,to_phone where key='3'  
  17. insert overwrite table youni_contact41_lxw partition(pt='4')  
  18. select phone,to_phone where key='4'  
  19. insert overwrite table youni_contact41_lxw partition(pt='5')  
  20. select phone,to_phone where key='5'  
  21. insert overwrite table youni_contact41_lxw partition(pt='6')  
  22. select phone,to_phone where key='6'  
  23. insert overwrite table youni_contact41_lxw partition(pt='7')  
  24. select phone,to_phone where key='7'  
  25. insert overwrite table youni_contact41_lxw partition(pt='8')  
  26. select phone,to_phone where key='8'  
  27. insert overwrite table youni_contact41_lxw partition(pt='9')  
  28. select phone,to_phone where key='9';  
 

该SQL产生11个job,第一个job为生成临时表的job,后续job都依赖它,这时不会有并行启动,

第一个job完成后,后续的job都会并行启动。

 

 

运行时间比较:

 

不启用并行:35分钟

启用8个并行:10分钟

启用16个并行:6分钟

 

当然,得是在系统资源比较空闲的时候才有优势,否则,没资源,并行也起不来。


http://superlxw1234.iteye.com/blog/1703713

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值