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 Development (2000)
 Index on Date Column

Author  Topic 

ramdas
Posting Yak Master

181 Posts

Posted - 2003-10-08 : 13:10:59
Hi Folks,
I have a table which has a column called datestamp which is of type datetime. The issue is whether to create a clustered index on the datestamp column or a nonclustered index. There going to queries performed on the table retrieving records based on a range of dates in the datestamp column.

For ex:
SELECT * FROM table_A
WHERE DateStamp BETWEEN '2003-09-01' AND '2003-10-01'

Thanks in advance

Ramdas Narayanan
SQL Server DBA

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-08 : 13:16:55
From BOL:

A clustered index is particularly efficient on columns that are often searched for ranges of values. After the row with the first value is found using the clustered index, rows with subsequent indexed values are guaranteed to be physically adjacent. For example, if an application frequently executes a query to retrieve records between a range of dates, a clustered index can quickly locate the row containing the beginning date, and then retrieve all adjacent rows in the table until the last date is reached. This can help increase the performance of this type of query. Also, if there is a column(s) that is used frequently to sort the data retrieved from a table, it can be advantageous to cluster (physically sort) the table on that column(s) to save the cost of a sort each time the column(s) is queried.

****

Just remember that you can only have one clustered index on a table, so you've got to use it wisely.


Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-10-08 : 13:19:21
Need more info..like how about the table DDL and size estimates..growth..

but I go for NONUNIQUE NONCLUSTERED



Brett

8-)

SELECT @@POST FROM Brain ORDER BY NewId()

That's correct! It's an AlphaNumeric!
Go to Top of Page
   

- Advertisement -