Search This Blog

Friday, August 10, 2007

What is the difference between Clustered Index and Non clustered index and what factors should I consider for Clustered Index?

Clustered Index defines the physical order of data storage and hence, only 1 clustered index is possible on a table.

In the Presence of Clustered index on a table, Non clustered index stores the indexed columns information along with clustered index key. In absence of Clustered index, Non Clustered Index stores ROWID. Max of 249 Non Clustered Indexes can be created on a table.

As I have the option of Only 1 clustered index can be created on a table, it is very critical to determine the right columns for clustered index.

I consider the following Attributes of column:

Columns in clustered index are not supposed to be updateable. Because, every time value in column in the clustered index is changed, SqL Server has to re-order the data pages.

Search Criteria:

Column should be searched for a given range.
Or
Column should be used for “Order by”
Or
Column should be used for “Group By”

No comments: