Hive连接查询性能

时间:2017-06-29 19:01:37

标签: sql hadoop hive

我想在A.id = B.id上将表A与B联系起来,如下所示:

select A.id,B.name from (select * from TABLEa)A 
LEFT JOIN (select * from TABLEb where partition IN ('GOP','LOP')B on A.id=B.id

这里我的TABLEb被两个值GOP和LOP分区。

我还尝试对以下方法进行相同的查询:

insert overwrite table final 
select A.id,B.name from (select * from TABLEa)A 
LEFT JOIN (select * from TABLEb where partition IN ('GOP')B on A.id=B.id;
insert INTOtable final 
select A.id,B.name from (select * from TABLEa)A 
LEFT JOIN (select * from TABLEb where partition IN ('LOP')B on A.id=B.id;

任何机构都能说出哪种方法应该更好吗?和理由或是什么使第二个不同于第一个。

请帮助

1 个答案:

答案 0 :(得分:0)

select
    A.id,
    B.name
from
    TABLEa as A 
    LEFT JOIN TABLEb as B on partition IN ('GOP','LOP') and A.id=B.id