From the course: SQL Server Performance for Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Choosing a PK or clustered index key

Choosing a PK or clustered index key - SQL Server Tutorial

From the course: SQL Server Performance for Developers

Start my 1-month free trial

Choosing a PK or clustered index key

- [Instructor] Beginning our next chapter of Indexing, we're going to talk about choosing a primary key and a clustering key. Frequently these things are the same and we'll talk about the benefits of that, but before we get into this topic I'd like to talk a little bit about the differences between clustered indexes and non-clustered indexes. This is something that's a little bit unique to SQL Server. Some other databases have similar functionality, particularly Sybase, but if you're coming from an Oracle or MySQL background it may be a little bit different to you. What a clustered index does is stores the entire table's pages in the order of the clustering key. When we talk about a clustered index it represents all of the data that's stored in the entire table. This is really good for things like doing order by or index range scans and it tells SQL Server how to order those pages and it uses a B-tree structure to do that. And really, when we talk about indexes, specifically we look…

Contents