hive里,同一sql里,会涉及到n个job,默认情况下,每个job是顺序执行的。
如果每个job没有前后依赖关系,可以并发执行的话,可以通过设置该参数 set hive.exec.parallel=true,实现job并发执行,该参数默认可以并发执行的job数为8。
[mw_shl_code=bash,true]set hive.exec.parallel=true;[/mw_shl_code]
例如:
[mw_shl_code=bash,true]sql="""
set hive.exec.parallel=true;
use database;
select a,b,c
from
(
select a1 as a,b1 as b,c1 as c from table1
union all
select a2 as a,b2 as b,c2 as c from table2
union all
select a3 as a,b3 as b,c3 as c from table3
...
)t;
"""[/mw_shl_code]
注意:
1、笔者原来一个任务有98个job,运行3h左右,经设置该参数后,运行10min,可见该参数设置会让sql跑的更快,效率大大提高,但是会占用大量的map和reduce资源;
2、可以通过hive.exec.parallel.thread.number来设置并发执行的job数,如下:
[mw_shl_code=bash,true]set hive.exec.parallel=true;
set hive.exec.parallel.thread.number=最大并发job数; [/mw_shl_code]
|