sql sp inner join slow performance

sql - the following SP works fine -- but really when adding the 2 inner joins ... the reason to add them is to cross-reference Agent/Discount column data.

why is this is ?   can this be speed up?  (without the inner joins -- the search returns back almost instantly ... when adding inner joins ... more than 10 seconds).
SELECT 
T3.[DistributorDisplayName] AS 'Agent',
T2.[Discount] AS 'Agent Discount ( % )',
T1.[MSISDN], 
T1.[Comments] AS 'Voucher', 
cast( Cast(isnull(T1.[ChargeableAmount], 0) AS DECIMAL(18,2)) / 100000 AS decimal(18,2))  'Top-Up Amount ( £ )' ,
cast( Cast(isnull(T1.[EndingBalance], 0) AS DECIMAL(18,2)) / 100000 AS decimal(18,2))  'Ending Bal ( £ )',
T1.[TransactionTime]

FROM [TDRData] T1
INNER JOIN [EMUK_BackOffice].[dbo].[Vouchers] T2 ON T2.[SerialNumber]  = T1.[Comments] COLLATE Latin1_General_CI_AS
INNER JOIN [EMUK_BackOffice].[dbo].[Distributors] T3 ON T2.[Distributor_ID] = T3.[Distributor_ID]

WHERE ((T1.[COSID] = 95) 
     AND (T1.[TransactionKey] = 1) 
     AND (T1.[TransactionTime] >= @TransactionTime)  
     AND (T1.[TransactionTime] <= @TransactionTime2))

ORDER BY T1.[TransactionTime] DESC

Open in new window

amillyardAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
in the query menu....
0
 
RGBDartCommented:
look at query execution plan in SSMS, and if it suggests you to create indexes - do so.
0
 
musalmanERP ConsultantCommented:
try :

WHERE ((T1.[COSID] = 95)
     AND (T1.[TransactionKey] = 1)
     AND (T1.[TransactionTime] BETWEEN @TransactionTime)  AND @TransactionTime2))
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
amillyardAuthor Commented:
'look at query execution plan in SSMS, and if it suggests you to create indexes - do so. ' -- where is the feature please in SSMS ? under Stored Procedures?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
in query => include actual execution plan, and run the query.
you will get a execution plan, which will show how the query is executed?
0
 
amillyardAuthor Commented:
angelIII: apologies - 'actual execution plan' -- what is this ?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
it's a graphical display of how the query is executed, showing index access vs full table access, and how "joins" are executed internally.
this helps to tune the query, showing where the query is behaving badly
0
 
amillyardAuthor Commented:
angelIII: within the SSMS - where is the option please?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.