Advertisement
Beginner SQL Server, Columnstore Indexes

What is the difference between a clustered columnstore index and a nonclustered columnstore index?

Short answer

A clustered columnstore index replaces the entire table's underlying storage with columnstore format and is typically used for large fact tables in a data warehouse, while a nonclustered columnstore index is added alongside an existing rowstore table, allowing the table to still…

Save SQL Server mock interview
Advertisement
AModel answer
A clustered columnstore index replaces the entire table's underlying storage with columnstore format and is typically used for large fact tables in a data warehouse, while a nonclustered columnstore index is added alongside an existing rowstore table, allowing the table to still support fast individual row lookups while also getting columnstore performance benefits for analytical queries.
-- Clustered columnstore replaces the table's storage entirely
CREATE CLUSTERED COLUMNSTORE INDEX CCI_Sales ON SalesFact;

-- Nonclustered columnstore is added alongside existing indexes
CREATE NONCLUSTERED COLUMNSTORE INDEX NCCI_Orders ON Orders (OrderDate, Amount, CustomerId);
Real-world example
An operational orders table keeps its regular clustered index for fast individual order lookups, while a nonclustered columnstore index is added on top to speed up occasional large analytical reports run against the same table.
Likely follow-ups
  • Can you combine a clustered columnstore index with additional nonclustered rowstore indexes?
  • Why would a table need both row based and column based indexing?
Related topics