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