Compress tables & indexes
The first two command check what will be the best way to compress. In our example we show the PAGE type compress.
Last updated:
Warning: Review and test in a non-production environment before running.
EXEC sp_estimate_data_compression_savings 'dbo', 'TABLE_NAME', NULL, NULL, 'ROW' ;
EXEC sp_estimate_data_compression_savings 'dbo', 'TABLE_NAME', NULL, NULL, 'PAGE' ;
create alter and rebuild (index & table)
----------------------------------------
WITH (DATA_COMPRESSION = PAGE)
ALTER TABLE table_name
REBUILD WITH (DATA_COMPRESSION = PAGE, MAXDOP=8);
ALTER INDEX table_index
ON tnuot
REBUILD
WITH ( DATA_COMPRESSION = PAGE, MAXDOP=8);