大多数的Hadoop Job是需要Hadoop提供完整的可扩展性来处理数据的。不过,有时Hive的输入数据量是非常小的。在这种情况下,为查询而触发执行任务消耗的时间可能会比实际job的执行时间要多的多。
大多数这种情况,Hive可以通过本地模式在单台机器上处理所有的任务。
本地模式对于小数据集,执行时间可以明显被缩短。
用户可以通过设置hive.exec.mode.local.auto的值为true,来让Hive在适当的时候自动启动本地模式这个优化。 对应的hive-site.xml中的配置信息
hive.exec.mode.local.auto
false
hive.exec.mode.local.auto.inputbytes.max
134217728
hive.exec.mode.local.auto.input.files.max
4
//开启本地模式 set hive.exec.mode.local.auto=true; //设置本地模式的最大输入数据量,当输入数据量小于这个值时采用本地模式的方式,默认为128M set hive.exec.mode.local.auto.inputbytes.max=50000000; //设置本地模式的最大输入文件个数,当输入文件个数小于这个值时采用本地模式,默认为4 set hive.exec.mode.local.auto.input.files.max=10;
示例: 第一步:使用默认模式:hive.exec.mode.local.auto=false 第二步:开启本地模式:hive.exec.mode.local.auto=true
发现两者执行时间相差一个数量级,还是很大的。