<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://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>Search results matching tags 'SQL Server 2008 R2' and 'row compression'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SQL+Server+2008+R2,row+compression&amp;orTags=0</link><description>Search results matching tags 'SQL Server 2008 R2' and 'row compression'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>SQL Server 2008 R2 : A quick experiment in Unicode Compression</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/11/sql-server-2008-r2-a-quick-experiment-in-unicode-compression.aspx</link><pubDate>Tue, 11 Aug 2009 18:17:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:15961</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;Fellow MVP &lt;a title="http://sqlblogcasts.com/blogs/simons/archive/2009/08/11/SQL2008-R2---Whats-New---Unicode-Compression.aspx" target="_blank" href="http://sqlblogcasts.com/blogs/simons/archive/2009/08/11/SQL2008-R2---Whats-New---Unicode-Compression.aspx"&gt;Simon Sabin blogged today&lt;/a&gt; about one of the few engine enhancements we'll be seeing in SQL Server 2008 R2 : Unicode compression. You can read more about &lt;a title="http://msdn.microsoft.com/en-us/library/ee240835%28SQL.105%29.aspx" target="_blank" href="http://msdn.microsoft.com/en-us/library/ee240835%28SQL.105%29.aspx"&gt;the topic in Books Online&lt;/a&gt;, but basically what is going to happen is that NCHAR / NVARCHAR (but not NVARCHAR(MAX)) columns, in objects that are row- or page-compressed, can benefit from additional compression, where realistically you can cut your storage requirements in half, depending on the language / character sets in use.&lt;br&gt;&lt;/p&gt;&lt;p&gt;But I'm the kind of guy who has to see it to believe it!&amp;nbsp; So, I mocked up a quick test of storing some &lt;strike&gt;Finnish&lt;/strike&gt; Danish/Norweigan (?) characters, and ran it both on a SQL Server 2008 instance (SP1 + CU3, 10.0.2723), and a SQL Server 2008 R2 instance (10.50.1092).&amp;nbsp; &lt;/p&gt;&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;USE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;tempdb&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;GO&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;SET&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;NOCOUNT&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;ON&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;GO&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.test&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;foo&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;NVARCHAR&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;2048&lt;/font&gt;&lt;font color="gray"&gt;))&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;WITH&amp;nbsp;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;DATA_COMPRESSION&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;ROW&lt;/font&gt;&lt;font color="gray"&gt;);&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;GO&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;INSERT&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.test&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;foo&lt;/font&gt;&lt;font color="gray"&gt;)&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;SELECT&amp;nbsp;&lt;/font&gt;&lt;font color="magenta"&gt;RTRIM&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="magenta"&gt;RAND&lt;/font&gt;&lt;font color="gray"&gt;())&amp;nbsp;+&amp;nbsp;&lt;/font&gt;&lt;font color="magenta"&gt;REPLICATE&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;N'øååøæ'&lt;/font&gt;&lt;font color="gray"&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;300&lt;/font&gt;&lt;font color="gray"&gt;);&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;GO&amp;nbsp;50000&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;EXEC&amp;nbsp;&lt;/font&gt;&lt;font color="darkred"&gt;sp_spaceused&amp;nbsp;&lt;/font&gt;&lt;font color="red"&gt;N'dbo.test'&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;GO&lt;/font&gt;&lt;font color="black"&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;DROP&amp;nbsp;TABLE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;dbo.test&lt;/font&gt;&lt;font color="gray"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font color="black"&gt;GO&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&lt;b&gt;SQL Server 2008 results:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;img border="1" height="69" width="378" src="http://aaronbertrand.com/voodoo/2008UCr.png"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL Server 2008 R2 results: &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;img border="1" height="74" width="366" src="http://aaronbertrand.com/voodoo/2008R2UCr.png"&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The difference is astounding: a space savings of roughly 60%, FOR FREE.&amp;nbsp; That's right, this is an enhancement you get just by upgrading... I did not do anything differently about the creation of these tables except continue to use compression.&amp;nbsp; (And note that I also performed this test with page compression, and the results were identical all around.)&amp;nbsp; Keep in mind that if you upgrade at some point (you can't upgrade to R2 in its present form), you will need to rebuild indexes in order to implement this new compression method across the entire table.&lt;br&gt;&lt;/p&gt;&lt;p&gt;And of course, by "free," I am not talking about the licenses.&amp;nbsp; As with row and page compression, this feature is only available in Developer, Enterprise, and Enterprise Evaluation editions.&lt;br&gt;&lt;br&gt;Now, I'll admit, the test is not super-realistic, and is biased toward good compression (since the same pattern is repeated over and over again on every row and on every page), and as such it demonstrates something pretty close to best-case scenario.&amp;nbsp; But even worst-case scenario is not exactly "bad" -- you may not see a gain at all, but you can't lose anything either, because the compression algorithm in SQL Server 2008 is smart enough to know when it is actually going to *lose* space by implementing compression, and won't do it in that case.&lt;br&gt;&lt;br&gt;At some point I will test the performance of writing, reading and seeking against a Unicode compressed table (and I will come up with more plausible test data at that point).&amp;nbsp; Because nothing is ever really free, is it?&amp;nbsp; Stay tuned to find out.&lt;br&gt;&lt;/p&gt;</description></item></channel></rss>