There are clustered and non-clustered indexes. A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.
A non-clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
A non-clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
Using DML (Data Manipulation Language) statement on cluster index column have performance issues since it has to update the index each and every time a DML gets executed.
Clustered Index
|
Non-Clustered Index
|
Only one per table
|
Can be used many times per table
|
There can be only 1 Clustered index in a table. This is usually made on the primary key. | Whereas non-clustered index can be up to 249 |
Clustered is physical sorted index |
A non clustered index is a special type of index in which the logical order of the index
|
Data retrieval faster
|
Insert and update statements faster
|
Leaf nodes in B-Tree structure contains actual rows.
|
Leaf pages in B-Tree structure contains pointers to actual rows.
|
Example
CREATE TABLE Student
(
StudID INT PRIMARY KEY CLUSTERED,FirstName VARCHAR(100),LastName VARCHAR(100),Address VARCHAR(100) UNIQUE NONCLUSTERED
)
GO
CREATE NONCLUSTERED INDEX Student_nonclust ON Student(FirstName)
GO
After creating the CLUSTERED and NONCLUSTERED index it will show like
Comments
Post a Comment