SQL Server: Check estimated data compression savings before compressing in SQL Server

Hi Friends,

In general, compression is a good thing. Even better, you can check the estimated compression savings before you actually compress. For example, you want to compress FactInternetSales table in AdventureWorksDW. Following is what you can do:

First you can check the size of the table:

use AdventureWorksDW
GO

EXEC sp_spaceused N'FactInternetSales'
GO

Next, you can estimate the compression savings using the sp_estimate_data_compression_savings stored procedure:

   

For row compression:

exec sp_estimate_data_compression_savings 
            'dbo', 'FactInternetSales', NULL, NULL, 'ROW'

For page compression:

exec sp_estimate_data_compression_savings 
            'dbo', 'FactInternetSales', NULL, NULL, 'PAGE'

The output is self-explanatory. It’s a good thing to calculate the savings rather than compress a very large table only to realize that you aren’t happy with the compression ratio.

 

 

   

About Amit Bansal

Amit Bansal is always brainstorming around SQL Server. Despite working with SQL since 1997, he is amazed that he keeps learning new things every single day. SQL Server is AB's first love, and his wife does not mind that. He tries to share as much and spreads the SQL goodness. Internals and Performance Tuning excites him, and also gives him sleepless nights at times, simply because he is not a genius, but quite a hard worker and does not give up. It has been a long and exciting journey since 1997, you can read here: http://sqlmaestros.com/amit-bansal/ He is on Twitter: https://www.twitter.com/A_Bansal

View all posts by Amit Bansal →

Leave a Reply

Your email address will not be published.