zoukankan      html  css  js  c++  java
  • 关于hive multi group by的疑惑

     有多条hive语句从同一张表中做count操作,语句如下:

     select pf,way,method,count(distinct id) where push_date_type ='$push_date_type' group by pf,way,method; 
    select pf,way,-1,count(distinct id) where push_date_type ='$push_date_type' group by pf,way;
     ......

      想着用multi group by特性优化下效率,于是把上述语句改写成:

    from push_revisit_info 
        insert overwrite table push_rpt_pf_way_mthd
            select pf,way,method,count(distinct id) where push_date_type ='$push_date_type' group by pf,way,method
        insert overwrite table push_rpt_pf_way
            select pf,way,-1,count(distinct id) where push_date_type ='$push_date_type' group by pf,way
    

    参数hive.multigroupby.singlemr也设置成了true;

    可是这条语句还是会生成两个mapreduce执行,跟未使用multi group by时MR Job数量一样,甚至执行时间还稍长。

    如果这两句的group key用成一样,就会只生成一个MR Job,但不论hive.multigroupby.singlemr是true还是false,都是这样。

    关于这个参数的含义,hive-default.xml是这样写的:

    <property>
        <name>hive.multigroupby.singlemr</name>
        <value>false</value>
        <description>Whether to optimize multi group by query to generate single M/R
            job plan. If the multi group by query has common group by keys, it will be
            optimized to generate single M/R job.</description>
    </property>

    这里的common翻译成什么最合适呢?“共同的”?那依上面的经验,不用开启这个设置也会优化成一个。那么这个参数到底有什么用?multi group by又如何使用呢?  

  • 相关阅读:
    springMVC 使用WebApplicationContext获取ApplicationContext对象
    idea for mac 最全快捷键整理
    装饰模式 应用场景和实现
    RabbitMQ基础知识详解
    jetty 介绍以及小例子
    业务对象的贫血模型与充血模型
    同构与异构
    Java设计模式之策略模式与状态模式
    C++之内部类(嵌套类)与外部类及友元
    深入理解Java中为什么内部类可以访问外部类的成员
  • 原文地址:https://www.cnblogs.com/aprilrain/p/2966125.html
Copyright © 2011-2022 走看看