Why not use compressed disk files or disk volumes?

When we think of compressing the database, one of the first question that pops up is why not used the compressed volume? You may know that Windows OS has supported compression of individual files, folders and the entire NTFS volumes since Windows 2000. Given this, you may wonder why don’t we just create databases on compressed volume and get the disk savings?

Well, there are few issues with it as follows

· Generally the compression methods are effective on large chunks of data. So you may need to compress many pages (think in mega bytes) together before you can get good compression. This runs counter to how data is actually accessed in the database. Most user queries access data “randomly” and in “small” parts. This means that accessing random data will force reading many pages on the compressed volume/file and this needs to be followed by decompression before the requested data can be retrieved. This becomes prohibitively more expensive.

· When data is read into the SQL Server memory (i.e. buffer pool), it is uncompressed. So there is no benefit from memory perspective either.

· The IO on compressed volume is synchronous which will impact the performance of your workload. Here is some information picked up from an excellent white paper written by Bob Dorr https://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlIObasics.mspx . “SQL Server relies heavily on asynchronous I/O capabilities to maximize resource usage. SQL Server Support has debugged problems with some filter drivers that do not allow the I/O request to be completed asynchronously. Instead, the filter driver requires the I/O to complete before returning control to SQL Server. This is easily observed by watching the disk queue lengths. When SQL Server is running, it commonly keeps more than one I/O posted. When I/Os become synchronous, the disk queue is often held at one outstanding I/O. This causes the SQL Server code to unnecessarily block. Because the disk sec/transfer time may not be a fair statistic, use it with caution. When less I/O is outstanding on a drive, the disk sec/transfer is often fast. The longer the disk queue length, the more variations that can occur on disk sec/transfer. However, because SQL Server understands the asynchronous nature of the I/O patterns, longer disk queue lengths, and somewhat longer disk sec/transfer can result in overall better throughput and resource utilization.”

In the next blog, I will describe how SQL Server compresses the data.