i have this query :
select distinct order_header.order_id
from order_header
LEFT JOIN order_rows on order_header.order_id=order_rows.order_id
where
( (TAARICH_HASPAKA >= 1112853600 AND TAARICH_HASPAKA <= 1113026399 AND (sent=’0′ OR sent=”)) OR (TAARICH_HASPAKA < 1112853600 AND TEUDAT_MISH=” AND (sent=’0′ OR sent=”) ) OR (TAARICH_TEUDA >= 1112853600 AND TAARICH_TEUDA <= 1112939999))
and region_id=’002′
when i run this query withought the left join i get results in seconds.
when i add the left join it takes 3 times more!
when i remove the
(which means go over all the regions it takes me 2-3 minutes at least!!!!)
currently i have in the order_header 50000 lines and in the order_rows i have 200000 lines!
i added some indexes but no luck
still everything is very very slow
what can i do?
thnaks in advance
peleg