You are here: Help to optimize query « MsSQL Server « IT news, forums, messages
Help to optimize query

Posted by bie2 on 05/18/06 22:56

Hi,
I have these two tables in a Database

ITEMS
ID numeric (Primary key)
ZDID nvarchar 3 (not null)
IDF_Family numeric (not null)
Description nvarchar 40 (not null)

DATAS
ID numeric (Primary Key)
IDF_Item numeric (Foreign key)
IDF_Reference numeric (Foreign Key)
[Date] smalldatetime (not null)
Container nchar 10 (not null)
Average decimal (not null)
[%Compliance] decimal (not null)
[%OutOfRange<MinTg] decimal (not null)
[%OutOfRange>MaxTg] decimal (not null)
Target decimal (not null)
[Min] decimal (not null)
[Max] decimal (not null)


The table DATAS has 4000000+ records

I'm running this query:

SELECT DISTINCT I.ID, I.ZDID, I.IDF_Family, I.Description
FROM Items as I, Datas as D
WHERE D.IDF_Item = I.ID AND I.IDF_Family = 84
AND D.Date BETWEEN '5/18/2004' AND '5/18/2004'

it's taking 4-5 minutes to run.
The result is correct, there is no thing on that date.
I've done a reindex, but still the same thing.

What can I do?

Thanks

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация