<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx</link><description>Enabling compression on your database can save you a lot of space – but when you have a lot of varchar(max) or nvarchar(max) data, you may find the savings to be limited. This is because only data stored on the data and index pages is compressed, and</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47411</link><pubDate>Thu, 31 Jan 2013 13:53:34 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47411</guid><dc:creator>Roger Plowman</dc:creator><description>&lt;p&gt;Thanks!&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47412</link><pubDate>Thu, 31 Jan 2013 15:31:34 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47412</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;I think a much simpler answer is: &amp;quot;because the SQL Server team didn't implement the feature due to it not meeting some internal priority bar.&amp;quot; It absolutely *could* be done -- there's no major technical barrier -- and it probably would by very useful for a lot of people. But they just didn't do it.&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47420</link><pubDate>Thu, 31 Jan 2013 17:26:07 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47420</guid><dc:creator>Hugo Kornelis</dc:creator><description>&lt;p&gt;@Adam: Of course it can be done. But can it be done without having a big adverse effect on performance?&lt;/p&gt;
&lt;p&gt;All the algorithms I know for effective compression of a single stream of bytes work on the basis of either a dictionary that is explcitly stored as part of the compressed data (e.g. Lempel–Ziv–WelchHuffman), or that is kept in memory only and can be reconstructed from the compressed data (e.g. Lempel–Ziv–Welch). Both categories have problems with SUBSTRING and chunked updates (the .WRITE method of the UPDATE statement).&lt;/p&gt;
&lt;p&gt;The first category always needs to read the dictionary in addition to the pages where the required data for a SUBSTRING lies, so more IO is needed for a SUBSTRING. It might even be necessary to read and decompress everything to the left of the substring, because I don't think it's possible to predict where exactly the 80,000th character of a compressed varchar(max) starts. For .WRITE, the same problem exists. And after too many .WRITE updates, the compression ratio will drop unless the dictionary is recalculated and the entire string is de- and then recompressed. Plus, what happens if I use .WRITE to replace a few character, but the replacement data doesn't compress as well as the original data?&lt;/p&gt;
&lt;p&gt;In the second category, it is even completely impossible to decompress a substring without first processing all the preceding bytes. And changing a chunk changes the dictionary, so any change would force the engine to de- and recompress everything that follows the changed part. Using .WRITE to replace a few characters near the start of a 750MB string can become very costly that way!&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47437</link><pubDate>Fri, 01 Feb 2013 09:32:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47437</guid><dc:creator>Peter</dc:creator><description>&lt;p&gt;Rather than compressing a 750MB string as a single stream, it would probably better to compress it in separate 1MB chunks which would then mean that SUBSTRING &amp;amp; .WRITE would only have to decompress/recompress a smaller section of the data.&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47451</link><pubDate>Sat, 02 Feb 2013 18:12:58 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47451</guid><dc:creator>Andrew</dc:creator><description>&lt;p&gt;@Peter excellent idea. Combined with fast algorithm, e.g. LZ4 (&lt;a rel="nofollow" target="_new" href="http://code.google.com/p/lz4/"&gt;http://code.google.com/p/lz4/&lt;/a&gt;), can yield substantial I/O savings.&lt;/p&gt;
&lt;p&gt;@Hugo I think compression is not for everybody. If you have an app that often updates 750MB row of data, then of course it's best to avoid compression. But SQL should support compression in scenarios where .WRITEs are used rarely or not used at all.&lt;/p&gt;
&lt;p&gt;So, we have cloud backup in SP1 CU2, may I expect LOB compression in SP1 CU3? :-)&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47456</link><pubDate>Sun, 03 Feb 2013 17:09:07 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47456</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Agreed with Andrew. The .write method is not especially common; I'm not sure I've seen it used more than one or two times. Make it a limitation of the feature and 95+% of people storing LOB data will be perfectly happy.&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47457</link><pubDate>Sun, 03 Feb 2013 21:15:01 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47457</guid><dc:creator>tobi</dc:creator><description>&lt;p&gt;The fact is that some scenarios would be conveniently addressed by being able to turn on a much stronger compression scheme that also works for LOB data. The disk space, buffer pool efficiency and IO savings can be worth the (enormous) CPU cost.&lt;/p&gt;
&lt;p&gt;SQL Server doesn't have this feature today but I hope they someday get around doing it. Maybe they are waiting until they have variable page size implemented so they can compress 1MB chunks at once.&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47458</link><pubDate>Sun, 03 Feb 2013 21:32:14 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47458</guid><dc:creator>tobi</dc:creator><description>&lt;p&gt;With a page size of &amp;gt;1MB one could use the same compression algorithm that is already used for backups. Backups would then not even need to compress again.&lt;/p&gt;
</description></item><item><title>re: Why does SQL Server not compress data on LOB pages?</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#47471</link><pubDate>Mon, 04 Feb 2013 13:46:08 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47471</guid><dc:creator>TheSQLGuru</dc:creator><description>&lt;p&gt;Small-chunk compression is the foundation of Column Store Indexing, which we know is very efficient and provides dramatic IO reduction and thus performance increases (even without Batch Mode Execution). &amp;nbsp;And like Adam I too have hardly EVER seen user apps doing LOB updating in the wild.&lt;/p&gt;
</description></item><item><title>Compression Presentation Resources | The SQL Herald</title><link>http://www2.sqlblog.com/blogs/hugo_kornelis/archive/2013/01/31/why-does-sql-server-not-compress-data-on-lob-pages.aspx#49015</link><pubDate>Thu, 09 May 2013 17:13:36 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:49015</guid><dc:creator>Compression Presentation Resources | The SQL Herald</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://joedantoni.wordpress.com/2013/05/09/compression-presentation-resources/"&gt;http://joedantoni.wordpress.com/2013/05/09/compression-presentation-resources/&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>