Configuring Data Compression

In this article we are going to configure Data compression in SQL Server 2008. Configuring data compression is very easy with just an couple of steps. The steps are below

  1. Estimate the Compression Ratio (Optional)
  2. Configure Data Compression

As I mentioned above first we need to estimate the compression ratio then only we can decide whether we can stick to that compression type, however this step is optional, you can configure without this step. You can configure Data compression in two ways as below

  • Configure through T-SQL
  • Configure through GUI

Lets configure data compression for a table in both the ways

Configure through T-SQL

*) Estimating compression ratio using page level compression. To know more about sp_estimate_data_compression_savings procedure parameters check the article http://msdn.microsoft.com/en-us/library/cc280574.aspx

/* Parameters for sp_estimate_data_compression_savings
@schema_name
@object_name
@index_id
@partition_number
@data_compression
*/
EXEC sp_estimate_data_compression_savings dbo,Compression_Test,1,NULL,PAGE

configure_data_compression_1

*) Configuring Data compression using page level compression

ALTER TABLE [dbo].[Compression_Test] REBUILD PARTITION = ALL
WITH
(
DATA_COMPRESSION = PAGE -- Specify the compression type here
)

configure_data_compression_2

*) Verify Data Compression setting for the table

SELECT partition_id,object_name(object_id) ObjectName
,data_compression_desc Data_Compression_Type
FROM sys.partitions WHERE data_compression <>0

configure_data_compression_3

Configure through GUI

*) Right click on the Table > Storage > Manage Compression

configure_data_compression_4

*) After clicking on Manage Compression, a new Data compression wizard will be started as below. Click on Next to continue

configure_data_compression_5

*) Select the compression type and click on Calculate button to estimate the compression ration (i.e size after compression), click on next to continue

configure_data_compression_6

*) You can either script it, schedule it or run immediately. In this example Im going to execute it immediately.

configure_data_compression_7

*) You will shown with the summary details before configuring, cross check it and click on Finish button to compress the object

configure_data_compression_8

*) The object will be compressed as shown below

configure_data_compression_9

*) To verify the compression status for the table, just right click on the table and click on properties. In the properties windows go to Storage tab there you can verify the compression status as shown below

configure_data_compression_10

Thats it you have now configured a table using Page level compression.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *