Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Cluster and Non-cluster index in SQL

Just for knowledge in interview question, and my knowledge.

SQL - Difference between Cluster and Non-cluster index?

like image 735
AjmeraInfo Avatar asked Mar 03 '10 18:03

AjmeraInfo


2 Answers

A link describing the two.

http://www.mssqlcity.com/FAQ/General/clustered_vs_nonclustered_indexes.htm

http://www.sql-server-performance.com/articles/per/index_data_structures_p1.aspx

The difference is in the physical order of the records in the table relative to the index. A clustered index is physically ordered that way in the table.

like image 57
kemiller2002 Avatar answered Sep 22 '22 15:09

kemiller2002


Cluster Index

1 A cluster index is a form of tables which consist of column and rows.
2 Cluster index exists on the physical level
3 It sorts the data at physical level
4 It works for the complete table
5 There is a whole table in form of sorted data 6 A table can contain only one cluster index

Non Cluster Index

1 A non cluster index is in the form of a report about the tables.
2 They are not created on the physical level but at the logical level
3 It does not sort the data at physical level
4 A table has 255 non clustered indexes
5 A table has many non clustered indexes.
6 It work on the order of data

like image 24
Nakul Chaudhary Avatar answered Sep 21 '22 15:09

Nakul Chaudhary