簡體   English   中英

減少大型查詢的執行時間

[英]Reduce the execution time of large query

我的查詢需要 30 多分鍾來處理此查詢。 它確實適用於非常大的數據集,但是我可能會遺漏一些可以減少執行時間的基本知識。

Query 在許多 reducer 階段工作,每個階段使用 1000 多個 reducer。 在 Tez 引擎上運行。

我嘗試啟用 CBO 但沒有運氣,也嘗試將減速器限制為 500,但執行時間仍然很長。

select itt.tr_date, sum (bkt_sum_pc) as pts 
from itops_trxn itt,
( select acttrxnID, max(act_cmp_id) as act_cmp_id 
   from itops_trxn_act a, ll_act_act_trxn b where a.act_trxn_ID = b.ACOUNTtrxnID group by  acttrxnID 
) A, 
(select cmp_id, max (cmp_name) as name 
   from itops_offer group by  cmp_id
) c 
where itt.acttrxnID = A.acttrxnID and act_cmp_id = c.cmp_id
and itt.type = 'ajstmnt' 
and itt.event_header_event_name NOT IN ('composite.sys.act.merge', 'pos.sys.identity', 'composite.sys.act.pcmerge') 
and itt.event_atomic_operation_type  = 'CT'
and itt.tr_date >='2018-10-31' 
group by itt.tr_date, channel, location_storeparentid, meta_trxnreason,  act_cmp_id,name; 

顯式重寫連接並移動這些條件

where itt.acttrxnID = A.acttrxnID and act_cmp_id = c.cmp_id

加入 ON 子句:

select itt.tr_date, sum (bkt_sum_pc) as pts 
from itops_trxn itt
INNER JOIN
( select acttrxnID, max(act_cmp_id) as act_cmp_id 
   from itops_trxn_act a, ll_act_act_trxn b where a.act_trxn_ID = b.ACOUNTtrxnID group by  acttrxnID 
) A           ON itt.acttrxnID = A.acttrxnID
INNER JOIN 
(select cmp_id, max (cmp_name) as name 
   from itops_offer group by  cmp_id
) c           ON A.act_cmp_id = c.cmp_id
where itt.type = 'ajstmnt' 
and itt.event_header_event_name NOT IN ('composite.sys.act.merge', 'pos.sys.identity', 'composite.sys.act.pcmerge') 
and itt.event_atomic_operation_type  = 'CT'
and itt.tr_date >='2018-10-31' 
group by itt.tr_date, channel, location_storeparentid, meta_trxnreason,  act_cmp_id,name; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM