[转]Hive:简单查询不启用Mapreduce job而启用Fetch task

时间:2023-01-08 17:06:22

转自:http://www.iteblog.com/archives/831

如果你想查询某个表的某一列,Hive默认是会启用MapReduce Job来完成这个任务,如下:

hive> SELECT id, money FROM m limit 10;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Cannot run job locally: Input Size (= 235105473) is larger than
hive.exec.mode.local.auto.inputbytes.max (= 134217728)
Starting Job = job_1384246387966_0229, Tracking URL = http://l-datalogm1.data.cn1:9981/proxy/application_1384246387966_0229/ Kill Command = /home/q/hadoop-2.2.0/bin/hadoop job
-kill job_1384246387966_0229
hadoop job information for Stage-1: number of mappers: 1;
number of reducers: 0
2013-11-13 11:35:16,167 Stage-1 map = 0%, reduce = 0%
2013-11-13 11:35:21,327 Stage-1 map = 100%, reduce = 0%,
Cumulative CPU 1.26 sec
2013-11-13 11:35:22,377 Stage-1 map = 100%, reduce = 0%,
Cumulative CPU 1.26 sec
MapReduce Total cumulative CPU time: 1 seconds 260 msec
Ended Job = job_1384246387966_0229
MapReduce Jobs Launched:
Job 0: Map: 1 Cumulative CPU: 1.26 sec
HDFS Read: 8388865 HDFS Write: 60 SUCCESS
Total MapReduce CPU Time Spent: 1 seconds 260 msec
OK
1 122
1 185
1 231
1 292
1 316
1 329
1 355
1 356
1 362
1 364
Time taken: 16.802 seconds, Fetched: 10 row(s)

我们都知道,启用MapReduce Job是会消耗系统开销的。对于这个问题,从Hive0.10.0版本开始,对于简单的不需要聚合的类似SELECT <col> from <table> LIMIT n语句,不需要起MapReduce job,直接通过Fetch task获取数据,可以通过下面几种方法实现:

方法一:

hive> set hive.fetch.task.conversion=more;
hive> SELECT id, money FROM m limit 10;
OK
1 122
1 185
1 231
1 292
1 316
1 329
1 355
1 356
1 362
1 364
Time taken: 0.138 seconds, Fetched: 10 row(s)

上面 set hive.fetch.task.conversion=more;开启了Fetch任务,所以对于上述简单的列查询不在启用MapReduce job!

方法二:

bin/hive --hiveconf hive.fetch.task.conversion=more

方法三:

上面的两种方法都可以开启了Fetch任务,但是都是临时起作用的;如果你想一直启用这个功能,可以在${HIVE_HOME}/conf/hive-site.xml里面加入以下配置:

<property>
<name>hive.fetch.task.conversion</name>
<value>more</value>
<description>
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 incurrs RS),
lateral views and joins.
1. minimal : SELECT STAR, FILTER on partition columns, LIMIT only
2. more : SELECT, FILTER, LIMIT only (+TABLESAMPLE, virtual columns)
</description>
</property>

这样就可以长期启用Fetch任务了

[转]Hive:简单查询不启用Mapreduce job而启用Fetch task的更多相关文章

  1. Hive之简单查询不启用MapReduce

    假设你想查询某个表的某一列.Hive默认是会启用MapReduce Job来完毕这个任务,例如以下: 01 hive> SELECT id, money FROM m limit 10; 02 ...

  2. Hive快捷查询&colon;不启用Mapreduce job启用Fetch task

    启用MapReduce Job是会消耗系统开销的.对于这个问题,从Hive0.10.0版本开始,对于简单的不需要聚合的类似SELECT <col> from <table> L ...

  3. Hive快捷查询:不启用Mapreduce job启用Fetch task三种方式介绍

    如果查询表的某一列,Hive中默认会启用MapReduce job来完成这个任务,如下: hive>select id,name from m limit 10;--执行时hive会启用MapR ...

  4. 011-HQL中级1-Hive快捷查询:不启用Mapreduce job启用Fetch task三种方式介绍

    如果你想查询某个表的某一列,Hive默认是会启用MapReduce Job来完成这个任务,如下: hive; Total MapReduce jobs Launching Job out since ...

  5. Hive笔记之Fetch Task

    在使用Hive的时候,有时候只是想取表中某个分区的前几条的记录看下数据格式,比如一个很常用的查询: select * from foo where partition_column=bar limit ...

  6. hive简单的项目实战

    解压user.zip [root@hadoop1 test]# unzip user.zip -d /test/bigdatacase/dataset Archive: user.zip inflat ...

  7. hive数据查询

    Fetch task 丢弃了mapreduce的作业的繁重任务,查询方便简单 1.第一种方式 2.linux命令行 3.地3中

  8. T-SQL简单查询语句

    简单查询: 1.最简单查询(查所有数据)select * from 表名: 注:* 代表所有列select * from info 2.查询指定列select code,name from info ...

  9. MySQL数据库6 -查询基础,简单查询,条件查询&comma;对查询结果排序

    一.SELECT语句 SELECT COL1,COL2,....COLn FROM TABLE1,TABLE2,....TABLEn [WHERE CONDITIONS] -- 查询条件 [GROUP ...

随机推荐

  1. &lbrack;Win32命令行&rsqb; 更改提示符字符串&lpar;PS1&rpar;

    当进入的目录比较深时, cmd的提示符几乎会占据整行, 很烦, 于是Google之... 参考: A better PROMPT for CMD.EXE ... 更改方式:        1. pro ...

  2. 使用siege进行Web压力测试

    因为最近公司线上node项目出一些不稳定的情况,考虑在这方面能不能做进一步的优化,既然要做优化首先要知道问题出在哪里? 因为暂无法定位是node层问题还是api层出现问题,由于在开发环境小并发量程序运 ...

  3. &lbrack;原&rsqb;My first Python

    我的第一个Python程序: print 'hello world' raw_input ("print any key to continue...") 在python3.4下应 ...

  4. 详解 jupyter notebook 集成 spark 环境安装

    来自: 代码大湿 代码大湿 1 相关介绍 jupyter notebook是一个Web应用程序,允许你创建和分享,包含活的代码,方程的文件,可视化和解释性文字.用途包括:数据的清洗和转换.数值模拟.统 ...

  5. Java 单链表的倒置

    在面试,笔试的过程中经常会遇到面试官问这种问题,实现单链表的倒置方法.现在对单链表的倒置犯法做个记录,方便自己以后查看. 单链表的定义: public class Node { int v; Node ...

  6. ubuntu 下安装nginx

    y@y:~$ sudo apt-get install nginx y@y:~$ sudo service nginx start y@y:~$ nginx默认使用80端口,打开浏览器输入:http: ...

  7. 基于SIFT&plus;Kmeans&plus;LDA的图片分类器的实现

    原地址:http://www.cnblogs.com/freedomshe/archive/2012/04/24/2468747.html 题记:2012年4月1日回到家,南大计算机研究僧复试以后,等 ...

  8. Html加载swf 兼容IE8 (含以下)显示

    嵌入参数说明: 1,AllowScriptAccess  参数: sameDomain:仅当 SWF 文件和网页位于同一域中时才允许执行外出脚本访问.这是 AVM2 内容的默认值----播放网络视频, ...

  9. FastDFS分布式文件系统

    FastDFS分布式文件系统 阅读目录 相关文章 1 分布式文件系统介绍 2 系统架构介绍 3 FastDFS性能方案 4 Linux基本命令操作 5 安装VirtualBox虚拟机并配置Ubuntu ...

  10. 【ASP&period;NET MVC系列】数据验证和注解

    [01]浅谈Google Chrome浏览器(理论篇) [02]浅谈Google Chrome浏览器(操作篇)(上) [03]浅谈Google Chrome浏览器(操作篇)(下) [04]浅谈ASP. ...