hive中not in优化
Posted starzy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于hive中not in优化的主要内容,如果未能解决你的问题,请参考以下文章