Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Speeding up Stored Procedure
Message
De
14/03/2013 14:09:21
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01568261
Message ID:
01568404
Vues:
42
>>>>
>>>>The tuning advisor does not run on SQL Express. I have the standard version of SQL 2012, do you think there'll be much difference if I do this in that version?
>>>>
>>>
>>>I'd run the query as-is in SQL 2012 to get your baseline, then run the tuning advisor.
>>
>>Thanks. I got it to run and followed the tuning advice and the query has gone from over 30 seconds to about 6.
>
>So what did it want you to do?


It had me create some indexes and statistics:
SET ANSI_PADDING ON

CREATE NONCLUSTERED INDEX [_dta_index_AirWayBills_9_7671075__K1_12] ON [dbo].[AirWayBills]
(
	[awb_pk] ASC
)
INCLUDE ( 	[awb_number]) WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]




CREATE NONCLUSTERED INDEX [_dta_index_CashReceipts_9_2061250398__K2_K3] ON [dbo].[CashReceipts]
(
	[crt_depfk] ASC,
	[crt_invfk] ASC
)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]


CREATE STATISTICS [_dta_stat_1163151189_1_4] ON [dbo].[Customers]([cus_PK], [cus_cntfk])

SET ANSI_PADDING ON

CREATE NONCLUSTERED INDEX [_dta_index_Customers_9_1163151189__K4_K1_2_3_5_21] ON [dbo].[Customers]
(
	[cus_cntfk] ASC,
	[cus_PK] ASC
)
INCLUDE ( 	[cus_lastname],
	[cus_firstname],
	[cus_company],
	[cus_number]) WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]


	CREATE STATISTICS [_dta_stat_747149707_4_2] ON [dbo].[InvoiceDetails]([ivd_amount], [ivd_invfk])

	CREATE STATISTICS [_dta_stat_20195122_2_11] ON [dbo].[Invoices]([inv_number], [inv_awbfk])

	CREATE STATISTICS [_dta_stat_20195122_1_11_4_2] ON [dbo].[Invoices]([inv_pk], [inv_awbfk], [inv_cusfk], [inv_number])

SET ANSI_PADDING ON

CREATE NONCLUSTERED INDEX [_dta_index_Invoices_9_20195122__K4_K1_K11_K2_3_5_6_7_8_9_10_12] ON [dbo].[Invoices]
(
	[inv_cusfk] ASC,
	[inv_pk] ASC,
	[inv_awbfk] ASC,
	[inv_number] ASC
)
INCLUDE ( 	[inv_date],
	[inv_pieces],
	[inv_weight],
	[inv_goodsvalue],
	[inv_printed],
	[inv_cancelled],
	[inv_insurance],
	[inv_cusnumber]) WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]
I also used the CTE suggested by Charles (I think) which took off a few more seconds.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform