第十章 Hive调优 【执行计划】

1. 语法
explain [extended | dependency | authorization] query

2. 从执行计划中 可以获取那些信息?
1. Job任务的DAG(有向无环图)
2. 操作算子
示例 : Fetch Operator
Select Operator
Map Reduce
Map Operator Tree
Reduce Operator Tree
Group By Operator

3. Fetch Operator
说明: Hive 中针对单表的查询,可以不用使用MapReduce程序,而是使用Fetch 直接读取存储文件
4. 开启hive Fetch 转换
      参数说明:
  none : 不开启 fetch 转换参数(所有的单表查询,都会转换成mr)
  minimal : 小粒度开启
转换条件 : 单表查询,where 只能为分区字段,limit
  more : 开启
转换条件 : 单表查询,where 可以表的任意字段,limit
  注意 : 默认为 more
      方式1 : 修改配置文件 (默认开启)
1. 配置文件名称 : hive-default.xml.template
     2. 修改项
复制代码
            <property>
            <name>hive.fetch.task.conversion</name>
            <value>more</value>
            <description>
              Expects one of [none, minimal, more].
              Some select queries can be converted to single FETCH task minimizing latency.
              Currently the query should be single sourced not having any subquery and should not have
              any aggregations or distincts (which incurs RS), lateral views and joins.
              0. none : disable hive.fetch.task.conversion
                  1. minimal : SELECT STAR, FILTER on partition columns, LIMIT only
              2. more    : SELECT, FILTER, LIMIT only (support TABLESAMPLE and virtual columns)
            </description>
            </property>
复制代码
  方式2 : 修改提交job参数 (会话级别)
  1. 不开启对单表查询
    set hive.fetch.task.conversion=none;
  2. 小粒度开启
    set hive.fetch.task.conversion=minimal;
  3. 开启
    set hive.fetch.task.conversion=more;

-- 测试
测试表 : 从1000w单表中 limit 111
none : 111 rows selected (23.842 seconds)
more : 111 rows selected (0.596 seconds)


 
posted @   学而不思则罔!  阅读(209)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示