T-SQL Tutorial

SQL Server Indexes

T-SQL indexes in SQL Server are used to improve the performance of queries. Indexes can be created on one or more columns in a table, and each index has a specific type. The most common types of indexes are hash, clustered, nonclustered, unique, columnstore, and index with included columns. An index can be created using the CREATE INDEX syntax.

SQL Server indexes can be a valuable tool for improving query performance. When creating indexes, it is important to consider the type of index, the columns that are being indexed, and the queries that will be using the index. By carefully choosing the right indexes for your data and your workload, you can see significant improvements in query performance.

Hash indexes

Hash indexes are used to store data in a hashing algorithm, which is used to speed up lookups.

Clustered indexes

Clustered indexes are used to store data in a specific order, which can be helpful for performance.

Nonclustered indexes

Nonclustered indexes are similar to clustered indexes, but the data is not stored in a specific order.

Unique indexes

Unique indexes are used to ensure that no two rows have the same value for the indexed column.

Columnstore indexes

Columnstore indexes are used to store data in a columnar format, which can improve query performance.

Indexes with included columns

Indexes with included columns are used to include additional columns in the index, which can improve performance.

Indexes on computed columns

Indexes on computed columns are used to store the results of a computation in an index. This can improve performance by avoiding the need to recompute the results of the computation every time the index is used.