MSDN

SQL Server Documentation

Index Types in SQL Server

Indexes improve the performance of data retrieval operations. SQL Server supports several index types, each optimized for specific scenarios.

Clustered Index

A clustered index determines the physical order of data rows in a table. A table can have only one clustered index.

CREATE CLUSTERED INDEX IX_Orders_OrderDate
ON dbo.Orders (OrderDate);
FeatureDescription
StorageData rows stored in B‑tree order.
UniquenessCan be defined as UNIQUE; otherwise, SQL Server adds a unique identifier.
Use CasesRange queries, sorting, primary key defaults.

Non‑Clustered Index

A non‑clustered index is a separate structure that contains a copy of indexed columns and a pointer to the data rows.

CREATE NONCLUSTERED INDEX IX_Products_Price
ON dbo.Products (Price) INCLUDE (ProductName, CategoryID);
FeatureDescription
StorageSeparate B‑tree holding key values and row locators.
Include ColumnsAdditional columns can be stored to cover queries.
Use CasesFrequent lookups on non‑key columns, covering indexes.

Columnstore Index

Columnstore indexes store data column‑wise, providing high compression and fast analytics performance.

CREATE CLUSTERED COLUMNSTORE INDEX IX_Sales_Columnstore
ON dbo.Sales;
FeatureDescription
CompressionUp to 75% reduction in storage size.
PerformanceOptimized for scans and aggregation.
LimitationsNot suitable for heavy point lookups.

Filtered Index

A filtered index is a non‑clustered index with a WHERE clause that indexes a subset of rows.

CREATE NONCLUSTERED INDEX IX_Orders_Active
ON dbo.Orders (CustomerID)
WHERE IsActive = 1;

Use filtered indexes to reduce index size and maintenance overhead for sparse data.

Unique Index

A unique index enforces the uniqueness of the indexed columns.

CREATE UNIQUE NONCLUSTERED INDEX IX_Employees_Email
ON dbo.Employees (Email);

Unique indexes automatically create a UNIQUE constraint if none exists.

XML Index

XML indexes improve the performance of queries on XML data types.

CREATE PRIMARY XML INDEX IX_Documents_XML
ON dbo.Documents (XmlColumn);

Secondary XML indexes (PATH, VALUE, PROPERTY) can further optimize specific query patterns.