为什么 Hive 中的 Fetch 任务比 Map-only 任务运行得更快?

lef*_*oin 1 optimization hadoop hive hive-configuration

可以使用 hivehive.fetch.task.conversion参数在 Hive 中启用 Fetch 任务以进行简单查询,而不是使用 Map 或 MapReduce。

请解释为什么 Fetch 任务比 Map 运行得快得多,特别是在做一些简单的工作时(例如select * from table limit 10;)?在这种情况下,什么仅地图任务还额外执行?在我的例子中,性能差异快了 20 倍以上。这两个任务都应该读取表数据,不是吗?

Kar*_*dep 6

FetchTask 直接获取数据,而 Mapreduce 会调用 MapReduce 作业

<property>
  <name>hive.fetch.task.conversion</name>
  <value>minimal</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>
Run Code Online (Sandbox Code Playgroud)

还有另一个参数hive.fetch.task.conversion.threshold,默认在 0.10-0.13 中为 -1,>0.14 为 1G(1073741824) 这表明,如果表大小大于 1G,则使用 Mapreduce 而不是 Fetch 任务

更多详情