hivesql求一段时间内每周_Hive SQL 经典优化案例

1b67181473ffcfaaf1b9f5d3667d893f.gif

声明 l 本文内容及图片来源于互联网,版权归原作者所有,仅供学习参考之用,禁止用于商业用途,侵删

c42e7bd3628f64910c6f1af7f3e7f238.png

HiveSQL经典优化案例一:

1.1 将要执行的查询(执行了 1个多小时才出结果):

SELECT dt as DATA_DATE,STRATEGY,AB_GROUP,SOURCE,    count(distinct case when lower(event) not like '%push%' and event!='corner_mark_show' then udid else null end) as DAU,    count(case when event='client_show' then 1 else null end) as TOTAL_VSHOW,    count(distinct case when event='client_show' then vid else null end) as TOTAL_VIDEO_VSHOW,    count(case when event='video_play' then 1 else null end) as TOTAL_VV_VP,    count(distinct case when event='video_play' then udid else null end) as TOTAL_USERS_VP,    count(case when event='effective_play' then 1 else null end) as TOTAL_VV_EP,    count(distinct case when event='effective_play' then udid else null end) as TOTAL_USERS_EP,    sum(case when event='video_over' then duration else 0 end) as TOTAL_DURATION,    count(case when event='video_over' then 1 else null end) as TOTAL_VOVER,    sum(case when event='video_over' then play_cnts else 0 end) as TOTAL_VOVER_PCNTS,    count(case when event='push_video_clk' then 1 else null end) as TOTAL_PUSH_VC,    count(distinct case when event='app_start' and body_source = 'push' then udid else null end) as TOTAL_PUSH_START,    count(case when event='post_comment' then 1 else null end) as TOTAL_REPLY,    count(distinct case when event='post_comment' then udid else null end) as TOTAL_USERS_REPLY    FROM dwb_v8sp_tmp.base_report_bystrategy_byab_source_column_zklgroup by dt,strategy,ab_group,source;

1.2 查询语句涉及到的表有 7.7亿+ 数据。(查询如下)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值