Hive優化之謂詞下推


Hive優化之謂詞下推

解釋

Hive謂詞下推(Predicate pushdown)

  1. 關系型數據庫借鑒而來,關系型數據中謂詞下推到外部數據庫用以減少數據傳輸

  2. 基本思想:盡可能早的處理表達式

  3. 屬於邏輯優化,優化器將謂詞過濾下推到數據源,使物理執行跳過無關數據

  4. 參數打開設置:hive.optimize.ppd=true

兩種生效形式

形式1:

select a.id,a.value1,b.value2 from table1 a
join (select b.* from table2 b where b.ds>='20181201' and b.ds<'20190101') c
on (a.id=c.id)

最推薦形式1的方法,雖然看着非常的土,但卻是最好的方法

形式2:

select a.id,a.value1,b.value2 from table1 a
join table2 b on a.id=b.id
where b.ds>='20181201' and b.ds<'20190101'

使用外連接失效

select a.id,a.value1,b.value2 from table1 a
left outer join table2 b on a.id=b.id
where b.ds>='20181201' and b.ds<'20190101'

討論

join、left join、right join、full outer join謂詞下推生效與失效的情況
基於上述討論總結一份PPD規則表

參考資料

Hadoop 過濾,映射,謂詞下推基本概念
hive謂詞下推的失效與生效
Hive中的Predicate Pushdown Rules(謂詞下推規則)

Changelog

181203創建
181130了解謂詞下推名詞


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM