Techie Baba

Wednesday, August 20, 2008

Clustered Index Vs Non-clustered Index

A database index is a data structure that is used for faster retrieval of data from a database table.

Clustered Indexing: Indexing is done on physical storage. Therefore you can have only one clustered index per table. Generally clustered index is built using Primary Key.

Non-clustered Indexing: Indexing is done logically. Therefore you can have multiple non-clustered indexes per table.

Since, a table can have just one Clustered Index, indexing need to be done carefully. In general scenario apply clustered index unique (PK), most queried column.

Sometime, you may need to work with other non-sorted columns such as Name, Description ( especially , varchar/char typed columns ). Then your physical data store cannot be ordered physically. In this case, you should use Non-Clustered Index for these columns. Because Non-Clustered Indexes can have logical sorting order.

This article has now moved to my new BLOG.

Labels: