Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sk237
Starting Member
1 Post |
Posted - 2012-03-23 : 12:15:57
|
How can i optimize the below query. it is taking alot of time to execute. any help is appreciated. delete from mdd.pat_program where patient_key IN ( select patient_key from mdd.pat_program join mdd.patient using (patient_key) join mdd.organization using (org_key) where dwkey_org = v_dwkey_org and dwkey_patient not in ( select distinct dwkey_patient from search.document_traits a join search.trait_map using (dwkey_org, dwkey_traittype) where dwkey_org = v_dwkey_org and global_traittype in (8, 9, 10) and trait_date > '01-JAN-2009' and out_of_range is null and dwkey_approval > 0 ) and dwkey_patient not in ( select distinct dwkey_patient from mdd.claim a join mdd.patient b on (a.org_key_provider = b.org_key and a.patient_key = b.patient_key) join mdd.organization c on (b.org_key = c.org_key) where dwkey_org = v_dwkey_org and dos_from > '01-JAN-2009' ) ); |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|