Сократить время выполнения большого запроса - PullRequest
0 голосов
/ 08 февраля 2019

Мой запрос занимает более 30 минут для его обработки.Это действительно работает с очень большим набором данных, однако я могу упустить что-то простое, что может сократить время выполнения.

Запрос работает на многих этапах редуктора, каждый из которых использует 1000+ редукторов.Работает на движке 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; 

1 Ответ

0 голосов
/ 08 февраля 2019

Переписать соединения явно и переместить эти условия

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

в предложение join 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; 
...