I have the below query in ORACLE which takes a really long time to run because of the OR in between the 2 likes.
select pat_mrn_id,surgery_date, proc_name
from or_log_all_proc, or_proc, or_log, patient
where
upper(proc_name) like ('%CRANIOTOMY ANEURYSM%') OR upper(proc_name) like
('CLIPPING%ANEURYSM')
Any help in writing the query efficiently would be appreciated. Thanks! JH
ORthat's the expensive part of theWHEREclause. It's the'LIKE '%anything%'. To solve that first condition every row in the database needs to be scanned. Try it with just the first condition and I doubt the performance will improve much at all. (Even after you fix the problem that you're cross joining 4 tables, as per the answers below)