Non Cluster Index

Опубликовано: 05 Октябрь 2024
на канале: Code with Salman
126
4

What is SQL Server Non-Clustered Index?
In the Non-Clustered Index, the arrangement of data in the index table will be different from the arrangement of data in the actual table. The data is stored in one place and the index table is stored in another place. Moreover, the index table will have pointers to the storage location of the actual data.
The only difference between the clustered and non-clustered index is how the leaf nodes are worked. In the case of a Clustered Index, the leaf node holds the actual data. On the other hand, the non-clustered index leaf-node has a Row Identifier (RID), and this Row ID pointing to different things based on the situations.
Situation1:
If your table does not have a clustered index, then the Row Identifier (RID) of the non-clustered index pointing to the heap table. A heap table is nothing but a table without indexes. In the heap table, it will search record row by row until it finds the data.

Situation2:
If your table has a clustered index, then the Row Identifier (RID) of the non-clustered index will point to the clustered index key and that indexed key is used to search the data.