[轉]Hive:簡單查詢不啟用Mapreduce job而啟用Fetch task

來源:互聯網
上載者:User

標籤:

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

如果你想查詢某個表的某一列,Hive預設是會啟用MapReduce Job來完成這個任務,如下:

hive> SELECT id, money FROM m limit 10;Total MapReduce jobs = 1Launching Job 1 out of 1Number of reduce tasks is set to 0 since there‘s no reduce operatorCannot 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_0229hadoop job information for Stage-1: number of mappers: 1; number of reducers: 02013-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 sec2013-11-13 11:35:22,377 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 1.26 secMapReduce Total cumulative CPU time: 1 seconds 260 msecEnded Job = job_1384246387966_0229MapReduce Jobs Launched:Job 0: Map: 1   Cumulative CPU: 1.26 sec   HDFS Read: 8388865 HDFS Write: 60 SUCCESSTotal MapReduce CPU Time Spent: 1 seconds 260 msecOK1       1221       1851       2311       2921       3161       3291       3551       3561       3621       364Time 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;OK1       1221       1851       2311       2921       3161       3291       3551       3561       3621       364Time 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.