Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Optimizing a SQL
Message
De
30/12/2009 15:02:25
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Optimizing a SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01441301
Message ID:
01441301
Vues:
94
I need to optimize the following SQL:
DECLARE @NoEntity Integer
DECLARE @Fic_Date DateTime
DECLARE @Fic_Date2 DateTime
DECLARE @First_Date DateTime

SET @NoEntity=3
SET @Fic_Date='2009-11-14 14:48:17'
SET @Fic_Date2='2009-11-15 14:48:17'
SET @First_Date='1899-12-30 00:00:00'

SELECT MAX(MitTelLogDet.Fic_Date) AS Last_Updated,MitTelLog.AI
 FROM MitTelLog (NOLOCK)
 INNER JOIN MitTelLogDet ON MitTelLog.AI=MitTelLogDet.MitTel_AI 
WHERE MitTelLog.NoEntity=@NoEntity AND MitTelLogDet.Fic_Date>=@Fic_Date
 AND MitTelLogDet.Fic_Date<=@Fic_Date2 AND
 MitTelLog.First_Date>@First_Date 
GROUP BY MitTelLog.AI
For some kind of reason, this doesn't seem to be optimized. Please, take in consideration that we have about two millions records in the main table and several millions in the child table. I need something that will work in just a few seconds as oppose to a minute.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform