Hive SQL触发MR的情况

本文详细介绍了Hive中hive.fetch.task.conversion参数如何影响作业执行,包括不同设置下哪些SQL操作会触发MR任务。总结了desc、select*、where条件筛选、count聚合、group by及order by等语句的执行机制,帮助理解Hive内部优化策略。
摘要由CSDN通过智能技术生成

Hive是否触发作业跟hive.fetch.task.conversion这个参数有关

参数分类:

  1. none
  2. minimal
  3. more(默认)
    可以在hive-default.xml.template 中查看
    在这里插入图片描述

测试语句:

  1. desc student;
  2. select * from student;
  3. select * from student where id in (“1”, “3”);
  4. select count(1) from student;
  5. select user, count(1) as user_count from student group by user;
  6. select user, count(1) as user_count from student group by user order by user desc

不走MR的情况结论

当hive.fetch.task.conversion=none的时候
  • 只有desc不走MR
当hive.fetch.task.conversion=minimal的时候
  • desc和select * 不走MR
当hive.fetch.task.conversion=more的时候
  • desc和select * 还有select * from live_info where traffic in (“1”, “3”);
    都不走MR

原理

下面做个大总结

  • 对于Describe table这种SQL语句,Hive会直接的从metastore去读取数据

  • 对于select * from table这种SQL查询语句,Hive不用经历map或者reduce过程

  • 对于select * from student where id in (“1”, “3”);
    这种SQL查询语句,Hive仅仅只有map,没有reduce,仅仅filter出id为"1","3"的记录

  • 对于select count(1) from student;
    这种SQL查询语句,只有reduce,没有map,但是如果我们除了count还需要取某个字段,reduce阶段之前还是需要走map的,比如说下面的SQL

  • 对于select user, count(1) as user_count from student group by user;
    这种SQL查询语句,除了要经历map阶段过滤出user字段,还要经历reduce阶段做聚合

  • 对于select user, count(1) as user_count from student group by user
    order by user desc;
    这种SQL查询语句,同样需要经历map和reduce阶段,不同的是,这条SQL语句有两个reduce,其中一个reduce用来排序保持全局排序好的结果。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值