map join的與Reduce Join效率對比

2021-06-28 04:31:04 字數 896 閱讀 9852

mapjion會把小表全部讀入記憶體中,在map階段直接拿另外乙個表的資料和記憶體中表資料做匹配,由於在map是進行了join操作,省去了reduce執行的效率也會高很多

使用乙個表測試,該錶時5分鐘表,資料很少,大概60多w。

測試日誌裡包含多個字段,其中有uid和uip。測試場景為給出2個uid,取uid共同的uip。

三個不同uid

select /*+ mapjoin(c) */

distinct  c.ip from

(select /*+ mapjoin(a) */

a.ip from 

(select ip from t where uid=uid1) a 

join

(select ip from t  where uid=uid2) b

on a.ip=b.ip 

) cjoin

(select ip from t where uid=uid3) d

on c.ip=d.ip

耗時 79.915 seconds  用4個mr

不適用mapjoin

select

distinct  c.ip from

(select

a.ip from 

(select ip from t where uid=uid1) a 

join

(select ip from t  where uid=uid2) b

on a.ip=b.ip 

) cjoin

(select ip from t where uid=uid3) d

on c.ip=d.ip

4個mr 耗時:90.932 seconds

結果一致.

效率提高了12%

map與reduce的用法

高階函式,接收函式作為輸入或輸出的函式 map 函式接收兩個引數,第乙個引數是乙個對資料處理的函式 這個函式只能接收乙個引數 第二個引數是乙個可迭代物件 map 函式的功能是對第二個引數中的每乙個元素使用資料處理的函式進行處理並返回處理後 的值 所以 map 函式返回的是乙個迭代器,迭代器執行的過程...

Python中的map與reduce函式簡介

1.從引數方面來講 map 函式 map 包含兩個引數,第乙個是引數是乙個函式,第二個是序列 列表或元組 其中,函式 即map的第乙個引數位置的函式 可以接收乙個或多個引數。reduce 函式 reduce 第乙個引數是函式,第二個是 序列 列表或元組 但是,其函式必須接收兩個引數。2.從對傳進去的...

reduce函式的用法

首先看reduce函式的官方解釋 python2 reduce reduce function,sequence initial value from left to right,so as to reduce the sequence to a single value.for example,r...