重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
此腳本運行速度慢,主要是reduce端數據傾斜導致的,了解到dw.fct_traffic_navpage_path_detl表是用來收集用戶點擊數據的,那么最終
創新互聯一直在為企業提供服務,多年的磨煉,使我們在創意設計,營銷型網站到技術研發擁有了開發經驗。我們擅長傾聽企業需求,挖掘用戶對產品需求服務價值,為企業制作有用的創意設計體驗。核心團隊擁有超過10余年以上行業經驗,涵蓋創意,策化,開發等專業領域,公司涉及領域有基礎互聯網服務綿陽機房托管、App定制開發、手機移動建站、網頁設計、網絡整合營銷。
購物車和下單的點擊肯定極少,所以此表ordr_code字段為空和cart_prod_id字段為NULL的數據量極大,如下所示:
select ordr_code,count(*) as a from dw.fct_traffic_navpage_path_detl where ds = '2015-05-10' group by ordr_code having a>10000 ;
151722135
select cart_prod_id,count(*) as a fromdw.fct_traffic_navpage_path_detl where ds = '2015-05-10' groupby cart_prod_id having a>10000 ;
NULL 127233335
對于create table tmp_lifan_trfc_tpa as這句SQL,BI加上如下配置,
set hive.mapjoin.smalltable.filesize = 120000000; //因為 dw.univ_parnt_tranx_comb_detl表最大不超過120MB,如果是hive on tez要用hive.auto.convert.join.noconditionaltask.size ,這樣tez會生成BROADCAST
sethive.auto.convert.join=true;
同時修改SQL如下語句:
from dw.fct_traffic_navpage_path_detl t
left outer join dw.univ_parnt_tranx_comb_detl o //用mapjoin解決數據傾斜
on t.ordr_code = o.parnt_ordr_code
and t.cart_prod_id = o.comb_prod_id
and o.ds = '2015-05-10'
left outer join bic.cust_first_ordr_tranx f
on case when o.end_user_id is null then cast(rand(9)*100as bigint) else o.end_user_id end= f.end_user_id //join后數傾斜用隨機數避免傾斜 ,紅色為修改部分
and f.first_ordr_date_id = '2015-05-10'
where t.ds = '2015-05-10';
運行后SQL可以在可控時間內完成。