How does columnstore compression work, and why does it typically achieve much higher compression ratios than regular row based storage?
Short answer
Columnstore compression groups similar values from the same column together, which allows SQL Server to use highly efficient compression algorithms since repeated or similar values compress very well, unlike row based storage which mixes many different data types and values…
Advertisement
AModel answer
Columnstore compression groups similar values from the same column together, which allows SQL Server to use highly efficient compression algorithms since repeated or similar values compress very well, unlike row based storage which mixes many different data types and values together within each row, limiting how effectively any single compression technique can work.
-- Columnstore automatically applies compression
-- You can also explicitly use columnstore archive compression
CREATE CLUSTERED COLUMNSTORE INDEX CCI_History
ON SalesHistory
WITH (DATA_COMPRESSION = COLUMNSTORE_ARCHIVE);Real-world example
A company archives years of historical sales data using columnstore archive compression, shrinking their storage footprint significantly compared to the original row based table while keeping the data still fully queryable.
Likely follow-ups
- What is the tradeoff between COLUMNSTORE and COLUMNSTORE_ARCHIVE compression?
- How much smaller does data typically become after columnstore compression?
Related topics