liveBook · Manning

Sp_estimate_data_compression_savings

As explained in 100 SQL Server Mistakes and How to Avoid Them

sp_estimate_data_compression_savings is a SQL Server system stored procedure that estimates storage savings from applying data compression to a table or index.

Mistake: compressing first and measuring later. Page compression may consume extra CPU without shrinking a table whose GUIDs and generated strings share little commonality. Estimate the result before changing a large table, especially on an I/O-bound instance with spare processor capacity. section 10.9

Estimate an alternative compression state

For the dbo.ImpressionsArchive clustered index, estimate the size without compression before rebuilding it: EXEC sp_estimate_data_compression_savings @schema_name = 'dbo', @object_name = 'ImpressionsArchive', @index_id = 1, @partition_number = NULL, @data_compression = 'none'; Compare the estimate with the current table and with row or page compression before implementation. In the ImpressionArchive scenario, page compression provided no additional reduction over row compression while requiring more decompression CPU. section 10.9

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Provides an executable estimate and comparison rationale, but does not detail the procedure's returned columns or result interpretation.
Examples
Uses dbo.ImpressionsArchive, random identifiers and strings, and a no-compression estimate for clustered index 1.
What you can do after
Evaluate expected storage savings and choose compression before rebuilding a large table.
How it connects
Connects data compression with row compression, page compression, CPU capacity, and I/O-bound workloads.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.