Hive join query for performance

2019-09-17 10:48发布

I want to left join Table A with B on A.id=B.id like below:

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

here my TABLEb is partitioned by two values GOP and LOP.

I also tried to do same query on following approach:

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;

Can any body tell which approach should be better? and reason or what makes second different than first one.

please help

标签: sql hadoop hive
1条回答
我想做一个坏孩纸
2楼-- · 2019-09-17 11:38
select
    A.id,
    B.name
from
    TABLEa as A 
    LEFT JOIN TABLEb as B on partition IN ('GOP','LOP') and A.id=B.id
查看更多
登录 后发表回答