I'm running the following query against two tables residing on an Oracle 8 database.
The query takes too long (over an hour) to run. Both tables are indexed - however the main table SALES.SO is HUGE. Does anyone have any suggestions as to how I could improve this query so it can execute faster.
Here's the main part of it:
SELECT s.cust_cd, d.st, d.reg REGION
FROM SALES.SO s AND devl.tblreg d
WHERE d.st = s.store_cd
AND s.wr_dt between v_dt and v_dt+28
AND s.so_wr_dt < to_date('&e_dt')+1
AND d.reg = 'STL'
AND (s.layaway = 'N')
OR s.layaway is null)
AND s.fin_cust_cd is null
Thanks for your help.