学无先后,达者为师

网站首页 编程语言 正文

hive not in效率优化

作者:NoOne-csdn 更新时间: 2022-04-01 编程语言

hive not in 效率忍不了

select
  shop_id
from
  whitelist
where
  date = '${date-1}'
  and shop_id not in (
    select
      shop_id
    from
      whitelist
    where
      date =  '${date-2}'
  )
  limit 20

愣是跑了十几分钟没完
修改后

select
  a.shop_id
from
  (
    select
      shop_id
    from
      whitelist
    where
      date = '${date-1}'
  ) a
  left join (
    select
      shop_id
    from
      whitelist
    where
      date = '${date-2}'
  ) b
on a.shop_id = b.shop_id
where
  b.shop_id is null

4s跑完

原文链接:https://blog.csdn.net/weixin_40161254/article/details/120545462

栏目分类
最近更新