Thursday, February 16, 2012

Clustered/Non-clustered Indexes and B-Trees

I would like to find information on Clustered and Non-clustered indexes and how B-trees are used. I know a clustered index is placed into a b-tree which makes sense for fast ordered searching. What data structure does a non-clustered index use and how?

I tried to find info. on the web but couldn't get much detail...I believe all indexes use B-Trees. The difference between a clustered and a non-clustered index is that the clustered index represents the way the records are actually stored in the database, and that is why a table can have only one clustered index.

Non-clustered indexes are stored separately from the table and reference the table's Primary Key.|||Why is it I always find the answer right after I post? :o

Correct me if I'm wrong but a non-clustered index stores the keys in a B-tree with the leaf level nodes containing pointers to the non-contiguous data pages.

A clustered index, however, also stores the keys in a B-tree but the leaves are the actual data pages ordered contiguously. The table data is physically ordered around the key.|||You said it, brother.

No comments:

Post a Comment