Hive MapJoin 优化

1、Hive本地MR

  如果在hive中运行的sql本身数据量很小,那么使用本地mr的效率要比分布式的快很多。但是hive本地MR对内存使用很敏感,查询的数据不能太大,否则本地内存是吃不消的。

So the query processor will launch this task in a child jvm, which has the same heap size as the Mapper's. Since the Local Task may run out of memory, the query processor will measure the memory usage of the local task very carefully. Once the memory usage of the Local Task is higher than a threshold number. This Local Task will abort itself and tells the user that this table is too large to hold in the memory. User can change this threshold by set  hive.mapjoin.localtask.max.memory.usage = 0.999

查询处理器会在一个子的jvm里运作这个任务,jvm堆大小跟Mapper的堆大小一样。本地MR可能内存消耗殆尽,查询处理器用精确的计算本地MR的内存大小,一旦内存超过了设定的值,那么这个MR就会自动kill掉。可以通过设置hive.mapjoin.localtask.max.memory.usage =0.9,这个值太保守。

set hive.exec.mode.local.auto=true;  //开启本地mr

//设置local mr的最大输入数据量,当输入数据量小于这个值的时候会采用local  mr的方式

set hive.exec.mode.local.auto.inputbytes.max=50000000;

//设置local mr的最大输入文件个数,当输入文件个数小于这个值的时候会采用local mr的方式

set hive.exec.mode.local.auto.tasks.max=10;

当这三个参数同时成立时候,才会采用本地mr

扫描二维码关注公众号,回复: 581694 查看本文章

2、Mapjoin使用

  就是把小的表加入内存,可以配置以下参数,是hive自动根据sql,选择使用common join或者map join

set hive.auto.convert.join = true;

hive.mapjoin.smalltable.filesize 默认值是25mb

猜你喜欢

转载自skywhsq1987.iteye.com/blog/2002565