justin11
asked on
Optimizing TSQL query
Hello,
I am running a query which takes about one hour.Can any one help me optimize it.
Here is the query:
Select * into #TAD from
OPENQUERY(DWDB, 'select DW_PR_SVC_LOAN_ID,DELQ_PRI N_AMT
as Total_Amt_Due from DW_PR_SVC_LOAN_MOD ')
Update tbl_MaestroCampaignList set TotalAmountDue = #TAD.Total_Amt_Due
from (tbl_MaestroCampaignList inner join #TAD
on tbl_MaestroCampaignList.DW _PR_SVC_LO AN_ID = #TAD.DW_PR_SVC_LOAN_ID)
where
datediff(day,GetDate(),cam paignDate) =0 and CampaignName ='FirstLienPreFCL'
I have to basically calculate Total Amount only for the loans in tbl_MaestroCampaignList .But I have to get these values from Datawarehouse table which has about a million loans. How to optimize it.
Thanks bunch
I am running a query which takes about one hour.Can any one help me optimize it.
Here is the query:
Select * into #TAD from
OPENQUERY(DWDB, 'select DW_PR_SVC_LOAN_ID,DELQ_PRI
as Total_Amt_Due from DW_PR_SVC_LOAN_MOD ')
Update tbl_MaestroCampaignList set TotalAmountDue = #TAD.Total_Amt_Due
from (tbl_MaestroCampaignList inner join #TAD
on tbl_MaestroCampaignList.DW
where
datediff(day,GetDate(),cam
I have to basically calculate Total Amount only for the loans in tbl_MaestroCampaignList .But I have to get these values from Datawarehouse table which has about a million loans. How to optimize it.
Thanks bunch
create this index it will speed upd the process a bit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the select into
or the update ?
which version of sql server?
why isn't the maestrocampaignlist in the warehouse?
why do you need to datediff on campaigndate?