hive中not in優化


比如:A,B兩表,找到ID字段中,存在A表,但不存在B表的數據。

          A表共13w,去重后3w,

          B表共2W,且有索引

方法一

not in,易理解,效率低,時間:1.395s

select distinct A.id from A where A.id not in(select id from B)

方法二

left...join...on ,B.id isnull    時間:0.739s

select A.ID from A left join B on A.ID=B.ID where B.ID is null

方法三

效率高,時間:0.57s

select * from  A where (select count(1) as num from B where A.ID = B.ID) = 0



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM