Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Optimizing TSQL query

Posted on 2006-06-21
5
Medium Priority
?
415 Views
Last Modified: 2012-05-05
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_PRIN_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_LOAN_ID = #TAD.DW_PR_SVC_LOAN_ID)
where
datediff(day,GetDate(),campaignDate)=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
0
Comment
Question by:justin11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 16951532
what takes the time
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?
0
 
LVL 28

Expert Comment

by:imran_fast
ID: 16952152
create this index it will speed upd the process a bit.
0
 
LVL 28

Accepted Solution

by:
imran_fast earned 2000 total points
ID: 16952160
create this index it will speed up the process a bit.

create nonclustered index ix_tbl_MaestroCampaignList_01 on tbl_MaestroCampaignList(CampaignName,DW_PR_SVC_LOAN_ID)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question