Skip to main content

What is Columnstore Index?

Editorial

Introduction

Up until now, every index we have discussed stores data row by row — these are called rowstore indexes. Columnstore indexes take a completely different approach: they store data column by column. This design is optimized for analytical queries that aggregate large volumes of data.

In this tutorial, you will learn:

  • What a columnstore index is and how it differs from rowstore
  • Why column-oriented storage is better for analytics
  • The concept of column segments and row groups
  • Compression benefits of columnstore indexes
  • When to use columnstore indexes

Row Storage vs Column Storage

To understand columnstore indexes, you first need to see the fundamental difference between how rowstore and columnstore organize data.

Visual comparison of rowstore and columnstore data layouts showing how columns are stored together for analytics efficiency

Why Columnstore is Faster for Analytics

Analytical queries typically have three characteristics that make columnstore indexes shine:

1. They Read Few Columns but Many Rows

-- This query reads ALL rows but only needs 1 column (amount)
SELECT SUM(price) FROM order_items;
Storage TypeData Read from Disk
RowstoreReads ALL columns of ALL rows (even unused columns)
ColumnstoreReads ONLY the price column

2. Compression is Much Better

When the same data type is stored together, compression algorithms work much more effectively:

ColumnValuesCompression
order_statusdelivered, delivered, delivered, shipped, delivered...Repeating values compress extremely well
customer_stateSP, SP, SP, RJ, SP, MG...Dictionary encoding: SP=1, RJ=2, MG=3
price150.00, 155.00, 149.00...Delta encoding: store differences only

Columnstore indexes typically achieve 10x compression compared to rowstore.

3. Batch Mode Processing

Columnstore indexes enable batch mode execution, where the query engine processes data in batches of up to 900 rows at once instead of one row at a time.

Generated visual representation from text diagram for Why Columnstore is Faster for Analytics.

Columnstore Architecture: Row Groups and Segments

Columnstore indexes organize data into two key structures:

Row Groups

Data is divided into chunks called row groups, each containing up to approximately 1,048,576 rows (about 1 million rows).

Column Segments

Within each row group, each column's data is stored as a compressed column segment.

Generated visual representation from text diagram for Columnstore Architecture: Row Groups and Segments.

Segment Elimination

Each column segment stores the minimum and maximum values it contains. When a query has a WHERE clause, SQL Server can skip entire segments that cannot contain matching data — this is called segment elimination.

SegmentMin ValueMax ValueQuery: WHERE Amount > 500
Segment 110.00200.00Skip (max < 500)
Segment 2150.00800.00Read (range overlaps)
Segment 35.0050.00Skip (max < 500)

Types of Columnstore Indexes

SQL Server offers two types of columnstore indexes:

TypeDescriptionKey Characteristics
Clustered ColumnstoreConverts the entire table to columnstore formatOne per table, replaces the rowstore table
Nonclustered ColumnstoreAdds a columnstore index alongside the existing rowstore tableCan coexist with a clustered rowstore index

When to Use Each

ScenarioRecommendation
Data warehouse / analytics tableClustered Columnstore
Table needs both fast point lookups AND analyticsNonclustered Columnstore + Clustered Rowstore
Reporting on an OLTP tableNonclustered Columnstore
Pure analytics, rarely updatedClustered Columnstore

Summary

Here is what you should remember about columnstore indexes:

ConceptKey Takeaway
WhatStores data column by column instead of row by row
Best forAnalytical queries: SUM, COUNT, AVG over millions of rows
Not ideal forPoint lookups (SELECT * WHERE id = X)
CompressionTypically 10x better than rowstore
Batch modeProcesses hundreds of rows at once for aggregations
Row groupsData is organized in ~1 million row chunks
Segment eliminationSkips irrelevant data based on min/max values

Rowstore vs Columnstore Quick Decision

WorkloadBest Index Type
OLTP (transactions, point lookups)Rowstore (Clustered + NonClustered)
OLAP (analytics, reporting)Columnstore
Mixed (both transactions and analytics)Rowstore + NonClustered Columnstore

In the next tutorial, you will learn the detailed process of how SQL Server builds a columnstore index.