I have a query which take data from 5 huge table, could you please help me with performance tuning of this query :
SELECT DECODE(SIGN((t1.amount - NVL(t2.amount, 0)) - 4.999), 1, NVL(t2.amount, 0), t1.amount) AS amount_1,
t1.element_id,
t1.start_date ,
t1.amount,
NVL(t5.abrev, NULL) AS criteria,
t1.case_id ,
NVL(t5.value, NULL) segment,
add_months(t1.start_date, -1) invoice_date,
NVL((SELECT SUM(b.amount)
FROM TABLE1 a, TABLE3 b
WHERE a.element_id = b.element_id
AND b.date_invoicing < a.start_date
AND t1.element_id = a.element_id),
0) amount_2
FROM TABLE1 t1, TABLE2 t2, TABLE3 t3, TABLE4 t4, TABLE5 t5
WHERE t1.TYPE = 'INVOICE'
AND t2.case_id = t3.case_id
AND t2.invoicing_id = t3.invoicing_id
AND t2.date_unpaid IS NULL
AND t1.element_id = t3.element_id(+)
AND add_months(t1.start_date, -1) <
NVL(t4.DT_FIN_DT(+), SYSDATE)
AND add_months(t1.start_date, -1) >= t4.date_creation(+)
AND t1.case_id = t4.case_id(+)
AND t4.segment = t5.abrev(+)
AND t5.Type(+) = 'CRITERIA_TYPE';
is there something wrong and could be replaced with something else?
Thanks for your help