Define clustered and non-clustered indexes

  • Clustered index: It’s used to sort data rows based on their key values. A clustered index is similar to a phone book’s contents. We may start with the letter ‘David’ (for ‘David, Thompson’) and discover information for all Davids right next to each other in the book. Because the data is stored adjacent to each other, it is much easier to retrieve data using range-based searches. Furthermore, the clustered index is linked to the data storage method. Per table, only one clustered index is possible.

  • Non-clustered index: It keeps data in one area and indexes in a different one. The index contains pointers that go to the data’s location. There can be multiple non-clustered indexes for a table since the index in the non-clustered index is stored in separate places.