Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Sql Server too slow

Author  Topic 

jai2808
Starting Member

27 Posts

Posted - 2008-12-04 : 07:36:37
Hi,
I have a table with nearly 9 lac records and while retreving, its taking lot of time 17-20mins.
I have Recordid as primary key and i pull the records between date range from front end using the following syntax

select recordid from log where convert(varchar,dated,101) between
@startdate and @enddate.

do i need to put an index on the dated column.
dated column contains date and time.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-04 : 07:44:24
Yes, you will need an index for "dated" column.
And also you will need to stop using convert on the dated column.

This will give you all records dated Dec 1, Dec 2 and Dec 3
DECLARE	@StartDate DATETIME,
@EndDate DATETIME

SELECT @StartDate = '2008-12-01',
@EndDate = '2008-12-04'

SELECT RecordID
FROM log
WHERE dated >= @startdate
and dated < @enddate



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -