I experimented with compression in SQL Server, but so far I have not seen the expected results.
To check, I created a new table with a single VARCHAR(8000) column VARCHAR(8000) and inserted 100k rows into it. Each line contains about 500 words of text, which, using ZIP compression, see more than 90% space savings.
I use the EXEC sp_estimate_data_compression_savings 'dbo', 'MyTable', NULL, NULL, 'PAGE' ; command EXEC sp_estimate_data_compression_savings 'dbo', 'MyTable', NULL, NULL, 'PAGE' ; to check how much space will be saved using PAGE compression, but this tells me that this will not happen. The results are as follows:
object_name schema_name index_id partition_number size_with_current_compression_setting(KB) size_with_requested_compression_setting(KB) sample_size_with_current_compression_setting(KB) sample_size_with_requested_compression_setting(KB) MyTable dbo 0 1 94048 93440 40064 39808
Basically this is not a saving. Where am I mistaken?
ps. I tried the same experiment with the NVARCHAR(4000) column, and compression there shows savings there, but I believe that this is due to the fact that forced compression uses 1 char instead of two, where the data does not require two characters. It actually does not compress the data in a way similar to a ZIP.
source share