Saturday, July 16, 2011

Clustered indexes Vs Non-clustered indexes




A clustered index is a special type of index that reorders the records in the table are physically stored. In non-technical way, you are telling the database to store close values to one another on the disk. This means, a table can have only one clustered index. This has the benefit of rapid scan / retrieval of records on any operation with clustered index values.
Writing to a table with a clustered index can reduce the speed, if clustered index is other than primary key. The reason is to rearrange the records.
For e.g.
I have two tables.
1) User
2) Order
User
———-
ID
Name
Address
Order
———-
ID
UserID
Price
If i need to get all orders of one user, than you can create clustered index on UserID of Order table. So all records of particular records will be physically stored to each other. This will speed up when we retrieve records.
A nonclustered index is a special type of index that stores the records in logical order rather than physical order. This means, a table can have many non clustered indexes. More non clustered indexes per table means more time it takes to write new records.

Reactions:

0 comments:

Post a Comment

Any Questions or Suggestions ?

About

Professional & Experienced Freelance Developer From India, Technologist, Software Engineer, internet marketer and Open Sources Developer with experience in Finance, Telecoms and the Media. Contact Me for freelancing projects.

Enter your email address:

Delivered by FeedBurner

PHP Freelancer India - Google+