<?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/"
	>

<channel>
	<title>SQL Statistics</title>
	<atom:link href="http://www.sqlstatistics.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sqlstatistics.com</link>
	<description>SQL Server Statistics</description>
	<pubDate>Sat, 11 Apr 2009 03:14:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title></title>
		<link>http://www.sqlstatistics.com/69/</link>
		<comments>http://www.sqlstatistics.com/69/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 02:53:39 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=69</guid>
		<description><![CDATA[In most cases it is wise to let SQL Server automatically update statistics.
To turn on automatic updates for all statistics in a database, if not already on, execute the following statement:
USE master
EXEC sp_dboption &#8216;MyDatabase&#8217;, &#8216; auto update statistics&#8217;, &#8216;true&#8217;
To turn on automatic updates for all statistics on a specific table, such as Clients, execute the [...]]]></description>
			<content:encoded><![CDATA[<p align="left">In most cases it is wise to let SQL Server automatically update statistics.</p>
<p align="left">To <strong><span style="color: #ff0000;">turn on automatic updates</span> for all statistics <span style="text-decoration: underline;">in a database</span></strong>, if not already on, execute the following statement:</p>
<p align="left"><span style="color: #0000ff;"><span class="textCode">USE master<br />
EXEC sp_dboption &#8216;MyDatabase&#8217;, &#8216; auto update statistics&#8217;, &#8216;true&#8217;</span></span></p>
<p align="left">To <strong><span style="color: #ff0000;">turn on</span> <span style="color: #ff0000;">automatic updates</span> for all statistics on a <span style="text-decoration: underline;">specific table</span></strong>, such as Clients, execute the following statement:</p>
<p align="left"><span style="color: #0000ff;"><span class="textCode">USE MyDatabase<br />
EXEC sp_autostats Clients, &#8216;ON&#8217;</span></span></p>
<p align="left">To <strong><span style="color: #ff0000;">manually update</span> the statistics on <span style="text-decoration: underline;">specific table</span></strong>, such as Clients, execute the following command:</p>
<p align="left"><span style="color: #0000ff;"><span class="textCode">USE MyDatabase<br />
UPDATE STATISTICS Clients</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/69/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Query to get the list of Indexes and Statistics and when they were updated</title>
		<link>http://www.sqlstatistics.com/query-to-get-the-list-of-indexes-and-statistics-and-when-they-were-updated/</link>
		<comments>http://www.sqlstatistics.com/query-to-get-the-list-of-indexes-and-statistics-and-when-they-were-updated/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 01:00:31 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=65</guid>
		<description><![CDATA[select
schemas.name as table_schema,
tbls.name as table_name,
i.name as index_name,
i.id as table_id,
i.indid as index_id,
i.groupid,
i.rowmodctr as modifiedRows,
(select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid &#60; 2) as rowcnt,
convert(DECIMAL(18,8), convert(DECIMAL(18,8),i.rowmodctr) / convert(DECIMAL(18,8),(select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid &#60; 2))) as ModifiedPct,
stats_date( i.id, i.indid ) as lastStatsUpdate,
&#8216;False&#8217; as Processed
into ##updateStatsQueue
from sysindexes i
inner join [...]]]></description>
			<content:encoded><![CDATA[<p>select<br />
schemas.name as table_schema,<br />
tbls.name as table_name,<br />
i.name as index_name,<br />
i.id as table_id,<br />
i.indid as index_id,<br />
i.groupid,<br />
i.rowmodctr as modifiedRows,<br />
(select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid &lt; 2) as rowcnt,<br />
convert(DECIMAL(18,8), convert(DECIMAL(18,8),i.rowmodctr) / convert(DECIMAL(18,8),(select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid &lt; 2))) as ModifiedPct,<br />
stats_date( i.id, i.indid ) as lastStatsUpdate,<br />
&#8216;False&#8217; as Processed<br />
into ##updateStatsQueue<br />
from sysindexes i<br />
inner join sysobjects tbls on i.id = tbls.id<br />
inner join sysusers schemas on tbls.uid = schemas.uid<br />
inner join information_schema.tables tl<br />
on tbls.name = tl.table_name<br />
and schemas.name = tl.table_schema<br />
and tl.table_type=&#8217;BASE TABLE&#8217;<br />
where 0 &lt; i.indid and i.indid &lt; 255<br />
and table_schema &lt;&gt; &#8217;sys&#8217;<br />
and i.rowmodctr &lt;&gt; 0<br />
and (select max(rowcnt) from sysindexes i2 where i.id = i2.id and i2.indid &lt; 2) &gt; 0</p>
<p>select * from ##updateStatsQueue</p>
<p>drop table ##updateStatsQueue</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/query-to-get-the-list-of-indexes-and-statistics-and-when-they-were-updated/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Query to get a list Statistics in the database (from sys.sysindexes table)</title>
		<link>http://www.sqlstatistics.com/query-to-get-a-list-statistics-in-the-database-from-syssysindexes-table/</link>
		<comments>http://www.sqlstatistics.com/query-to-get-a-list-statistics-in-the-database-from-syssysindexes-table/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 00:27:16 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=62</guid>
		<description><![CDATA[Query to get a list Statistics in the database (from sys.sysindexes table)
select name, rowcnt, rowmodctr,* from sys.sysindexes where rowcnt = 0 and name like &#8216;%_WA%&#8217;

All Statistics objects in the sys.sysindexes have rowcnt = 0 and its name starts from &#8216;_WA&#8217;
]]></description>
			<content:encoded><![CDATA[<p>Query to get a list Statistics in the database (from sys.sysindexes table)</p>
<p><span style="color: #0000ff;">select name, rowcnt, rowmodctr,* from sys.sysindexes where rowcnt = 0 and name like &#8216;%_WA%&#8217;<br />
</span></p>
<p>All Statistics objects in the <span style="color: #008000;"><strong>sys.sysindexes</strong></span> have rowcnt = 0 and its name starts from &#8216;_WA&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/query-to-get-a-list-statistics-in-the-database-from-syssysindexes-table/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Run SP_RECOMPILE after SP_UPDATESTATS</title>
		<link>http://www.sqlstatistics.com/run-sp_recompile-after-sp_updatestats/</link>
		<comments>http://www.sqlstatistics.com/run-sp_recompile-after-sp_updatestats/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 00:10:55 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=59</guid>
		<description><![CDATA[SP_UPDATESTATS refers to work against all user-defined tables in the current database.
For the stored procedures performance you need to recompile them in order to take the new plan in to the memory, so run SP_RECOMPILE for all or required stored procedures to compare the sequence of performance.
]]></description>
			<content:encoded><![CDATA[<p><strong>SP_UPDATESTATS</strong> refers to work against all user-defined tables in the current database.</p>
<p>For the stored procedures performance you need to recompile them in order to take the new plan in to the memory, so run <strong>SP_RECOMPILE</strong> for all or required stored procedures to compare the sequence of performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/run-sp_recompile-after-sp_updatestats/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to do the UPDATE STATISTICS in SQL Server?</title>
		<link>http://www.sqlstatistics.com/how-to-do-the-update-statistics-in-sql-server/</link>
		<comments>http://www.sqlstatistics.com/how-to-do-the-update-statistics-in-sql-server/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 00:02:16 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=56</guid>
		<description><![CDATA[If you want to find out if an index has had its indexes updated or not, you can use the command, like this:
DBCC SHOW_STATISTICS (table_name , index_name)

This command will not only tell you when statistics were last updated, but also provide you information on the kind of statistics that has been collected for the index [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to find out if an index has had its indexes updated or not, you can use the command, like this:</p>
<p><span style="color: #0000ff;">DBCC SHOW_STATISTICS (table_name , index_name)<br />
</span></p>
<p>This command will not only tell you when statistics were last updated, but also provide you information on the kind of statistics that has been collected for the index you are examining.</p>
<p>You can update the statistics using this command:<br />
<span style="color: #0000ff;">USE &lt;database_name&gt;<br />
EXEC sp_updatestats</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/how-to-do-the-update-statistics-in-sql-server/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How does SQL Server know when to update statistics?</title>
		<link>http://www.sqlstatistics.com/how-does-sql-server-know-when-to-update-statistics/</link>
		<comments>http://www.sqlstatistics.com/how-does-sql-server-know-when-to-update-statistics/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 00:00:41 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=54</guid>
		<description><![CDATA[SQL Server follows a very specific set of rules on when it should update the statistics of an index. Here they are:
- If the number of rows in a table are greater than 6, but less than or equal to 500, then statistics are automatically updated when there have been 500 modifications made.
- If the [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server follows a very specific set of rules on when it should update the statistics of an index. Here they are:<br />
- If the number of rows in a table are greater than 6, but less than or equal to 500, then statistics are automatically updated when there have been 500 modifications made.<br />
- If the number of rows in the table are greater than 500, then updates are automatically made when (500 plus 20 percent of the number of rows in the table) have been modified.</p>
<p>If you like, you can check to see how many modifications have been made to a table, and at the same time estimate when an automatic statistics update will occur. If you go to the sysindexes table of the database in question, and look at the rowmodctr column, it will show you what the count is.</p>
<p><span style="color: #0000ff;">select rowmodctr,* from sys.sysindexes </span></p>
<p>From this number, you can estimate when the next automatic update of statistics will occur.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/how-does-sql-server-know-when-to-update-statistics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What is UPDATE STATISTICS ?</title>
		<link>http://www.sqlstatistics.com/what-is-update-statistics/</link>
		<comments>http://www.sqlstatistics.com/what-is-update-statistics/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 23:51:35 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=51</guid>
		<description><![CDATA[SQL Server keeps statistics about the distribution of the key values in each index and uses these statistics to determine which index(es) to use in query processing. Users can create statistics on nonindexed columns by using the CREATE STATISTICS statement.
Query optimization depends on the accuracy of the distribution steps:
-	If there is significant change in the [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Server keeps <span style="color: #ff0000;"><strong>statistics about the distribution of the key values <span style="text-decoration: underline;">in each index</span> and uses these statistics to determine which index(es) to use in query processing</strong></span>. Users can create statistics on <span style="text-decoration: underline;"><span style="color: #0000ff;"><strong>nonindexed columns</strong></span></span> by using the CREATE STATISTICS statement.</p>
<p>Query optimization depends on the accuracy of the distribution steps:<br />
-	If there is significant change in the key values in the index, rerun UPDATE STATISTICS on that index.<br />
- If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated, use UPDATE STATISTICS.</p>
<p>Statistics can be created or updated on tables with <span style="color: #ff0000;"><strong>computed columns</strong></span> only if the <span style="color: #ff0000;">conditions are such that an index can be created on these columns</span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/what-is-update-statistics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reason why Update Stats with SAMPLE may take longer then with FULLSCAN</title>
		<link>http://www.sqlstatistics.com/reason-why-update-stats-with-sample-may-take-longer-then-with-fullscan/</link>
		<comments>http://www.sqlstatistics.com/reason-why-update-stats-with-sample-may-take-longer-then-with-fullscan/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 21:39:43 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=47</guid>
		<description><![CDATA[FULLSCAN is the same as SAMPLE RATE 100 with the difference that with SAMPLE RATE, SQL Server 2005 might adjust the rate up (and use a sample rate that is sufficiently high to create useful statistics) and if the requested rate creates more values than is considered needed, it &#8220;tries to match the requested sample [...]]]></description>
			<content:encoded><![CDATA[<p>FULLSCAN is the same as SAMPLE RATE 100 with the difference that with SAMPLE RATE, SQL Server 2005 might adjust the rate up (and use a sample rate that is sufficiently high to create useful statistics) and if the requested rate creates more values than is considered needed, it &#8220;tries to match the requested sample amount&#8221;. I&#8217;m not a 100% how it is in 2005, but in 2000 it would actually revert to FULLSCAN if the sample rate exceeded some threshold (for performance). You can check which sample rate you end up with DBCC SHOWSTATISTICS&#8230; WITH STAT_HEADER.</p>
<p>Now Update States with SAMPLE may take longer then with FULLSCAN, the explanation to that probably lies in how samples are gathered. Thing is, when you use a sample rate, <strong>SQL Server needs to figure out an access path (heap/cl idx/non-cl idx) and it <span style="color: #ff0000;">will try to find one that is NOT physically sorted on the first column in the statistics</span>.</strong> <strong>It does this to provide a more random sample</strong> and thus more accurate statistics. For FULLSCAN, this is not an issue so the lowest cost access path is chosen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/reason-why-update-stats-with-sample-may-take-longer-then-with-fullscan/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SQL script to find NULL statistics if they exist</title>
		<link>http://www.sqlstatistics.com/sql-script-to-find-null-statistics-if-they-exist/</link>
		<comments>http://www.sqlstatistics.com/sql-script-to-find-null-statistics-if-they-exist/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 21:28:24 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=44</guid>
		<description><![CDATA[SELECT &#8216;update statistics&#8217; + &#8216; &#8216; + RTRIM(object_name(I.id)) + &#8216; &#8216; + RTRIM(name)
/* DATALENGTH (statblob) size,
STATS_DATE (I.id, I.indid) last_updated */
FROM
sysindexes as I
WHERE
OBJECTPROPERTY(I.id, N&#8217;IsUserTable&#8217;) = 1 AND
INDEXPROPERTY (I.id , name , &#8216;IsAutoStatistics&#8217; ) = 1 AND
DATALENGTH (statblob) is null
]]></description>
			<content:encoded><![CDATA[<p><span style="color: #0000ff;">SELECT &#8216;update statistics&#8217; + &#8216; &#8216; + RTRIM(object_name(I.id)) + &#8216; &#8216; + RTRIM(name)</p>
<p>/* DATALENGTH (statblob) size,<br />
STATS_DATE (I.id, I.indid) last_updated */<br />
FROM<br />
sysindexes as I</p>
<p>WHERE<br />
OBJECTPROPERTY(I.id, N&#8217;IsUserTable&#8217;) = 1 AND<br />
INDEXPROPERTY (I.id , name , &#8216;IsAutoStatistics&#8217; ) = 1 AND<br />
DATALENGTH (statblob) is null</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/sql-script-to-find-null-statistics-if-they-exist/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SP_UPDATESTATS - updates statistics on tables which were modified recently</title>
		<link>http://www.sqlstatistics.com/sp_updatestats-updates-statistics-on-tables-which-were-modified-recently/</link>
		<comments>http://www.sqlstatistics.com/sp_updatestats-updates-statistics-on-tables-which-were-modified-recently/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 21:21:30 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sqlstatistics.com/?p=41</guid>
		<description><![CDATA[You can run sp_updatestats against the database, it will update the statistics on those tables which were modified recently.
]]></description>
			<content:encoded><![CDATA[<p>You can run sp_updatestats against the database, it will update the statistics on those tables which were modified recently.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlstatistics.com/sp_updatestats-updates-statistics-on-tables-which-were-modified-recently/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
