I have a query which involves joins across 7 different tables.
Below is the query:
SELECT /*+qb_name(select1) dynamic_sampling(nbtd 2) */
td.tsf_no C1
,td.tsf_seq_no C2
,NVL(th.from_loc,-999) C3
,NVL(th.to_loc,-999) C4
,NVL(th.to_loc_type,'-1') C5
,NVL (s.to_loc,'-999') C6
,td.item C7
,NVL(ss.qty_expected, 0) C8
,NVL(ss.carton,'-1') C9
,NVL(ss.distro_no,'-1') C10
,NVL(ss.distro_type,'-1') C11
,NVL(ss.qty_expected, 0) C12
,NVL(ss.weight_received, 0) C13
,NVL(ss.weight_received_uom, 0) C14
,s.shipment C15
,NVL(s.bol_no,'-1') C16
,NVL(s.order_no, 1) C17
,ils.av_cost C18
,il.unit_retail C19
,user C20
,to_char(sysdate, 'YYYYMMDD') C21
,'T' C22
,ss.seq_no C23
,nbtd.expense_ind C24
,nbtd.process_expense_ind C25
,to_char(th.create_date, 'YYYYMMDD') C26
FROM nb_tsfdetail nbtd
,tsfdetail td
,tsfhead th
,shipsku ss
,shipment s
,item_loc il
,item_loc_soh ils
WHERE td.tsf_no = nbtd.tsf_no
AND td.tsf_seq_no = nbtd.tsf_seq_no
AND td.tsf_no = th.tsf_no
AND ss.distro_no = td.tsf_no
AND ss.item = td.item
AND ss.shipment = s.shipment
AND td.item = il.item
AND il.loc = th.from_loc
AND ils.item = il.item
AND ils.loc = il.loc
AND nbtd.process_expense_ind = 'N'
AND nbtd.expense_ind = 'Y';
The data in each table is:
select count(1) from nb_tsfdetail;--692,336,190
select count(1) from tsfdetail;--693,317,818
select count(1) from tsfhead;--3,697,876
select count(1) from shipsku;-- 1,273,823,438
select count(1) from shipment;--514,593,396
select count(1) from item_loc;-- 109,587,391
select count(1) from item_loc_soh;--108,435,856
I have attached the explain of the above query.