Reputation: 16639
Can a Clustered index store the actual physical data in the order of the index?
Upvotes: 1
Views: 538
Reputation: 432471
Extending other answers...
Upvotes: 1
Reputation: 74315
Most SQL database implementations structure a database table without indices in the form of a heap — an unordered collection of related pages, each containing some number of rows.
Non-clustered indices are B-trees, the leaf nodes of which contain pointers to the data pages containing that key value. Getting a non-key value via a non-clustered index requires an additional lookup to retrieve the data page in question.
Clustered indices, like non-clustered indices, are B-trees, with one important difference: the heap goes away. The leaf nodes of the clustered index are the data pages for the table: thus giving physical order to the table. The rows on each page, likewise are maintained in key order. Getting a non-key value via a clustered index doesn't require the overhead of of the additional lookup required to get the data page in question.
Upvotes: 1
Reputation: 65187
That's what they do.
A clustered index is all the data in the table, stored in the physical order of the clustering key and with a supporting b-tree structure for quick navigation.
Upvotes: 2
Reputation: 58491
From MSDN
A clustered index determines the physical order of data in a table. A clustered index is analogous to a telephone directory, which arranges data by last name. Because the clustered index dictates the physical storage order of the data in the table, a table can contain only one clustered index. However, the index can comprise multiple columns (a composite index), like the way a telephone directory is organized by last name and first name.
So yes, a key point of a Clustered Index is to store the physical data in the order of the index.
Upvotes: 0
Reputation: 6766
A clustered index is an exact copy of the table, sorted by the field(s) of the index.
Upvotes: 0