最近使用hive带条件去查询hbase,count(1)只需要花费时间400秒,而查询其中的一个字段却花费3个多小时。
原因是因为hive去查询hbase的数据没有走MR,而是交给了某一个节点走localtask。
可以设置如下参数:
set hive.fetch.task.conversion=minimal;
强制hive走MR。
这个参数还有另外一个值:more,是强制hive不走MR。
上面的两种方法都可以开启了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> |