I have the following simple query with 2 table joins and a WHERE
clause.
I already indexed the key joining fields as well as the WHERE
clause field.
These 2 tables have about 123 million rows which is pretty huge. It takes about 7/8 hours to complete the full query below. I indexed and not sure what else to do since it's such a simple query with a JOIN
& WHERE
clauses:
insert into dbo.IMS_CLAIMS(CLAIM_ID
,DX_CLAIM_ID
,SVC_SEQ_NBR
,SVC_DT
,ALLWD_AMT
,BILL_AMT
)
select h.CLAIM_ID
,h.DX_CLAIM_ID
,s.SVC_SEQ_NBR
,h.SVC_DT
,s.ALLWD_AMT
,s.BILL_AMT
from [2016Q4_VITALS_EXPORT_HEADERS] as h
inner join [2016Q4_VITALS_EXPORT_SERVICE] as s
on h.claim_id = s.claim_id
where cast(SVC_DT as date) >= '2015-10-01'
and cast(SVC_DT as date) <= '2016-11-30';
Estimated Execution Plan: