在hive的查詢中,大部分都會出發一個MapReduce操作,但是在hive中,某些情況可以不必使用MapReduce,也就是所謂的本地操作模式。
如圖是執行MapReduce的過程。
1.當時用select * from tableName情況下,Hive可以簡單的讀取table對應的存儲目錄下的文件,然后輸出格式化后的文件到控制台。對於在where條件中使用分區字段這種情況,也是無需MapReduce過程的,例如select * from tableName where partition1=‘’;無論使用limit語句限制記錄條數。
2.如果屬性hive.exec.mode.local.auto的值設置為true的話,Hive還會嘗試使用本地模式執行其他的操作:
set hive.exec.mode.local.auto=true;
注意:最好是將set hive.exec.mode.local.auto=true這個設置增加到$HOME/.hiverc配置文件中。