我應該在蜂巢中創建和刪除中間表嗎?Hive SQL編碼風格:中間表?
我可以寫類似(大大簡化):
drop table if exists tmp1;
create table tmp1 as
select a, b, c
from input1
where a > 1 and b < 3;
drop table if exists tmp2;
create table tmp2 as
select x, y, z
from input2
where x < 6;
drop table if exists output;
create table output as
select x, a, count(*) as count
from tmp1 join tmp2 on tmp1.c = tmp2.z
group by tmp1.b;
drop table tmp1;
drop table tmp2;
或者我可以把一切都變成一個聲明:
drop table if exists output;
create table output as
select x, a, count(*) as count
from (select a, b, c
from input1
where a > 1 and b < 3) t1
join (select x, y, z
from input2
where x < 6) t2
on t1.c = t2.z
group by t1.b;
顯然,如果我重複一次以上的中間表,它對創建它們非常有意義。 但是,當他們只用一次,我有一個選擇。
我嘗試都和第二個是6%,如通過壁時間測量更快,但4%如由MapReduce Total cumulative CPU time
日誌輸出測量較慢。 這種差異可能在隨機誤差範圍內(由其他進程& c引起)。 但是,組合查詢有可能導致戲劇性的加速嗎?
另一個問題是:是僅使用一次的中間表,是蜂房代碼中的正常情況,還是應該在可能的情況下避免使用?
取代它如何找出一個參數的當前值,如'hive.exec.parallel'? – sds
只需在Hive控制檯中鍵入'set;',就可以得到參數列表及其值。 –