假设你想查询某个表的某一列。Hive默认是会启用MapReduce Job来完毕这个任务,例如以下:

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

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

  方法一:

01 hive>
set hive.fetch.task.conversion=more;
02 hive>
SELECT id, money FROM m limit 
10;
03 OK
04 1       122
05 1       185
06 1       231
07 1       292
08 1       316
09 1       329
10 1       355
11 1       356
12 1       362
13 1       364
14 Time
taken: 
0.138 seconds,
Fetched: 
10 row(s)

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

  方法二:

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

  方法三:

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

01 <property>
02   <name>hive.fetch.task.conversion</name>
03   <value>more</value>
04   <description>
05     Some
select queries can be converted to single FETCH task
06     minimizing
latency.Currently the query should be single
07     sourced
not having any subquery and should not have
08     any
aggregations or distincts (which incurrs RS),
09     lateral
views and joins.
10     1.
minimal : SELECT STAR, FILTER on partition columns, LIMIT only
11     2.
more    : SELECT, FILTER, LIMIT only (+TABLESAMPLE, virtual columns)
12   </description>
13 </property>

这样就能够长期启用Fetch任务了,非常不错吧。也赶紧去试试吧!

Hive之简单查询不启用MapReduce的更多相关文章

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

    转自:http://www.iteblog.com/archives/831 如果你想查询某个表的某一列,Hive默认是会启用MapReduce Job来完成这个任务,如下: hive> SEL ...

  2. Hive快捷查询:不启用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 的简单使用及调优参考文档

    Hive 的简单使用及调优参考文档   HIVE的使用 命令行界面 使用一下命令查看hive的命令行页面, hive --help --service cli 简化命令为hive –h 会输出下面的这 ...

  6. Hive[6] HiveQL 查询

    6.1   SELECT ... FROM 语句    hive> SELECT name,salary FROM employees;    --普通查询 hive>SELECT e.n ...

  7. Hive将SQL转化为MapReduce的过程

    Hive将SQL转化为MapReduce的过程: Antlr定义SQL的语法规则,完成SQL词法,语法解析,将SQL转化为抽象语法树AST Tree 遍历AST Tree,抽象出查询的基本组成单元Qu ...

  8. T-SQL简单查询语句

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

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

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

随机推荐

  1. ECCV 2014 Results (16 Jun, 2014) 结果已出

    Accepted Papers     Title Primary Subject Area ID 3D computer vision 93 UPnP: An optimal O(n) soluti ...

  2. KJBitmap使用方法

    摘要 本文原创,转载请注明地址:http://kymjs.com/code/2015/03/25/01 摘要 好像最近一个月都没有写博客了,正好伴着KJFrameForAndroid 更新v2.14版 ...

  3. arcgis runtime 100 Create geometries

    1 /* Copyright 2016 EsriEsri 2 * 3 * Licensed under the Apache License, Version 2.0 (the "Licen ...

  4. python接口自动化24-有token的接口项目使用unittest框架设计

    获取token 在做接口自动化的时候,经常会遇到多个用例需要用同一个参数token,并且这些测试用例跨.py脚本了. 一般token只需要获取一次就行了,然后其它使用unittest框架的测试用例全部 ...

  5. UITableView分页

    UITableView分页上拉加载简单,ARC环境,源码如下,以作备份: 原理是,点击最后一个cell,触发一个事件来处理数据,然后reloadData RootViewController.m + ...

  6. [翻译] AFNetworking 2.0

    大名鼎鼎的开源网络库AFNetworking 2.0,目前只是翻译了Github上的链接文章,使用教程请点击 http://www.cnblogs.com/YouXianMing/p/3651462. ...

  7. eclipse 开发web程序,启动tomcat插件服务器的时候。部署目录在那里?

    不在tomcat-home/webapps/下面, 你做一个文件上传功能看看就知道了,临时目录一般是你的工作区间workspace\.metadata\.plugins\org.eclipse.wst ...

  8. python 中面向对象编程的几个概念

    Python super() 函数 super() 函数是用于调用父类(超类)的一个方法. super 是用来解决多重继承问题的,直接用类名调用父类方法在使用单继承的时候没问题,但是如果使用多继承,会 ...

  9. 使用SqlServer中的float类型时发现的问题

    在做项目中,使用了float类型来定义一些列,如:Price,但是发现了很多问题1.当值的位数大于6位是float型再转varchar型的时候会变为科学技术法显示    此时只好将float型转换成n ...

  10. [置顶] Spring中自定义属性编辑器

    Spring中的属性编辑器能够自动的将String类型转化成需要的类型,例如一个类里面的一个整型属性,在配置文件中我们是通过String类型的数字进行配置的,这个过程中就需要一个转化操作,当然这个转化 ...