Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Speeding up Stored Procedure
Message
From
13/03/2013 17:51:15
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Speeding up Stored Procedure
Miscellaneous
Thread ID:
01568261
Message ID:
01568261
Views:
73
I'm using the following in a Stored Procedure to pull out some data for a report. Unfortunately it's running too slowly and timing out when I call the Dataset.Fill().
	SELECT [inv_awbfk],
		[inv_cancelled],
		[inv_cusfk],
		[inv_cusnumber],
		[inv_date],
		[inv_goodsvalue],
		[inv_insurance],
		[inv_number],
		[inv_pieces],
		[inv_pk],
		[inv_printed],
		[inv_weight] 
		,cus_company
		,cus_lastname
		,cus_firstname
		,cus_number
		,cnt_code
		,inv_total = (SELECT SUM(ivd_amount) FROM InvoiceDetails WHERE ivd_invfk = inv_pk)
		,awb_number
		,asatdate = @crt_date
	FROM [dbo].[Invoices]
		INNER JOIN Customers on inv_cusfk = cus_pk
		INNER JOIN AirWayBills on inv_awbfk = awb_pk
		INNER JOIN Countries ON cus_cntfk = cnt_pk
	WHERE inv_pk NOT IN (SELECT crt_invfk 
							FROM CashReceipts 
								INNER JOIN Deposits on crt_depfk = dep_pk 
							WHERE dep_date <= @crt_date)
	ORDER BY inv_number
Any suggestions for speeding this up?

I've got indexes on all the joined fields.

Is there a way for me to post the execution plan here?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform