<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Articles &#187; Compression</title>
	<atom:link href="http://www.sqldba.co.nz/blog/?feed=rss2&#038;cat=16" rel="self" type="application/rss+xml" />
	<link>http://www.sqldba.co.nz/blog</link>
	<description></description>
	<lastBuildDate>Thu, 27 Jul 2017 19:31:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>Working with SQL Server data compression</title>
		<link>http://www.sqldba.co.nz/blog/?p=79</link>
		<comments>http://www.sqldba.co.nz/blog/?p=79#comments</comments>
		<pubDate>Mon, 03 Dec 2012 23:36:28 +0000</pubDate>
		<dc:creator><![CDATA[brentm]]></dc:creator>
				<category><![CDATA[Compression]]></category>

		<guid isPermaLink="false">http://www.sqldba.co.nz/blog/?p=79</guid>
		<description><![CDATA[﻿ Before compressing any database, a check to see whether ROW or PAGE compression will give the best result is necessary before carrying out any change. The script below will generate a set of scripts to run and the output you can use &#8230; <a href="http://www.sqldba.co.nz/blog/?p=79">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="_mcePaste" class="mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;">﻿</div>
<p>Before compressing any database, a check to see whether ROW or PAGE compression will give the best result is necessary before carrying out any change. The script below will generate a set of scripts to run and the output you can use to determine what level of compression you should use &#8211; based on what (if any) savings will be gained with a certain compression type. The stored procedure that determines this is sp_estimate_data_compression_savings. Obviously you could compress all tables however you will get more bang for your buck if you compress the larger tables so I&#8217;ve purposely set the script to only show those tables with 50,000 or more pages.</p>
<pre>SELECT
'EXEC sys.sp_estimate_data_compression_savings @schema_name = '+SchemaName+'
                                             , @object_name = '+TableName+'
                                             , @index_id = 1
                                             , @partition_number = NULL
                                             , @data_compression = ROW'
FROM (SELECT    SCHEMA_NAME(schema_id) AS SchemaName
              , t.name AS TableName
              , SUM(total_pages) AS TotalPages
      FROM      sys.allocation_units AS a
                JOIN sys.partitions AS p ON a.container_id = p.partition_id
                INNER JOIN sys.tables AS t ON p.object_id = t.object_id
      WHERE     p.data_compression = 0
      GROUP BY  SCHEMA_NAME(schema_id)
              , t.name
      HAVING    SUM(total_pages) &gt; 50000
    ) AS x
ORDER BY x.SchemaName ASC</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sqldba.co.nz/blog/?feed=rss2&#038;p=79</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
