Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimizing a SQL
Message
From
30/12/2009 15:02:25
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Optimizing a SQL
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01441301
Message ID:
01441301
Views:
93
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
Next
Reply
Map
View

Click here to load this message in the networking platform