Estimated reading time: 2 minutes
In SQL, a clustered index is a type of index that determines the physical order of the data in a table.
It organizes the table data based on the values in one or more columns, and stores the data in the table accordingly. When a clustered index is created on a table, the rows of the table are stored on disk in the same order as the index.
Why would you create a clustered index?
There are several reasons as follows:
- They can improve the performance of queries performed on a table.
- As a result, the Detection of the data you require is more efficient and quicker, as the data is grouped together in the clusters.
Here are some key features of a clustered index:
- A clustered index can be created on only one table per database.
- A clustered index determines the physical order of the table data, and thus it affects the performance of queries that access the table.
- A clustered index is usually created on columns that are frequently used in queries as search criteria or that are frequently sorted or grouped.
It’s worth noting that creating a clustered index on a table can be a time-consuming operation, as it involves reordering the table data on a disk.
Finally, it’s important to carefully consider the columns to use for a clustered index, as the wrong choice can actually decrease query performance.