<?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>Database Statistics &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/database-statistics/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 03 Apr 2018 19:13:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: Improve Query Performance by Extended Statistics</title>
		<link>https://www.dbrnd.com/2018/04/postgresql-improve-query-performance-by-extended-statistics/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 03 Apr 2018 19:13:15 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[correlated column]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Database Statistics]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[extended statistics]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[query performance]]></category>
		<category><![CDATA[statistic object]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6916</guid>

					<description><![CDATA[<div><img width="635" height="357" src="https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Performance.jpg" class="attachment-post-image size-post-image wp-post-image" alt="" decoding="async" fetchpriority="high" /></div>In this post, I am sharing an important demonstration on how to improve query performance by adding Extended Statistics in PostgreSQL. PostgreSQL: Important Statistics Table, Used by the Query Planner The database statistics are always important in any database system. Because query optimizer is creating Query Execution Plan basis on stored database statistics. Understand below [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="635" height="357" src="https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Performance.jpg" class="attachment-post-image size-post-image wp-post-image" alt="" decoding="async" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&amp;linkname=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&amp;linkname=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&amp;linkname=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&amp;linkname=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&amp;linkname=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&amp;linkname=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-improve-query-performance-by-extended-statistics%2F&#038;title=PostgreSQL%3A%20Improve%20Query%20Performance%20by%20Extended%20Statistics" data-a2a-url="https://www.dbrnd.com/2018/04/postgresql-improve-query-performance-by-extended-statistics/" data-a2a-title="PostgreSQL: Improve Query Performance by Extended Statistics"></a></p><p>In this post, I am sharing an important demonstration on how to improve query performance by adding Extended Statistics in PostgreSQL. </p>
<blockquote class="wp-embedded-content" data-secret="5NUC2ue1WC"><p><a href="https://www.dbrnd.com/2016/09/postgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze/">PostgreSQL: Important Statistics Table, Used by the Query Planner</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/09/postgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze/embed/#?secret=5NUC2ue1WC" data-secret="5NUC2ue1WC" width="600" height="338" title="&#8220;PostgreSQL: Important Statistics Table, Used by the Query Planner&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>The database statistics are always important in any database system. Because query optimizer is creating Query Execution Plan basis on stored database statistics. </p>
<p>Understand below official note which copied from <a href="https://www.postgresql.org/docs/10/static/planner-stats.html#idm46428702517264" rel="noopener" target="_blank">here</a>.</p>
<blockquote><p>It is common to see slow queries running bad execution plans because multiple columns used in the query clauses are correlated. </p>
<p>The planner normally assumes that multiple conditions are independent of each other, an assumption that does not hold when column values are correlated. Regular statistics, because of their per-individual-column nature, cannot capture any knowledge about cross-column correlation. </p>
<p>Because the number of possible column combinations is very large, it&#8217;s impractical to compute multivariate statistics automatically. Instead, extended statistics objects, more often called just statistics objects.</p></blockquote>
<p>Let me explain, by my way, </p>
<blockquote><p>For example, you give two filters in a where condition like zip code and city_name.<br />
Now, zip code is unique for dataset, but one city has multiple zip codes.<br />
Now, this both conditions and columns called correlated columns. </p>
<p>To inform the planner about functional dependencies, ANALYZE can collect measurements of cross-column dependency.<br />
It is advisable to create dependencies statistics only for column groups that are strongly correlated, to avoid unnecessary overhead in both ANALYZE and later query planning.</p></blockquote>
<p>Check the below demonstration:</p>
<p><strong>Create a sample table:﻿</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_TestStats
 (
     ID SERIAL
     ,CodeDate TIMESTAMPTZ
     ,CodeName TEXT
 );</pre> </p>
<p><strong>Two sample insert for different series:</strong><br />
For example, 2016 year for code &#8216;abc&#8217; and 2017 year for code &#8216;xyz&#8217;</p>
<pre class="crayon-plain-tag">INSERT INTO tbl_TestStats 
(CodeDate, CodeName)
SELECT x, 'abc' 
FROM generate_series('2016-01-01 00:00:00'::timestamptz, '2016-12-31 00:00:00'::timestamptz,'10 seconds'::interval) a(x);


INSERT INTO tbl_TestStats 
(CodeDate, CodeName)
SELECT x, 'xyz' 
FROM generate_series('2017-01-01 00:00:00'::timestamptz, '2017-12-31 00:00:00'::timestamptz,'10 seconds'::interval) a(x);</pre> </p>
<p><strong>Total inserted records:</strong></p>
<pre class="crayon-plain-tag">SELECT COUNT(1) FROM tbl_TestStats
-- '6298562'</pre> </p>
<p><strong>Now, Execute ANALYZE:</strong></p>
<pre class="crayon-plain-tag">ANALYZE tbl_TestStats;</pre> </p>
<p><strong>Check the execution plan of the below query:</strong></p>
<pre class="crayon-plain-tag">EXPLAIN ANALYZE
SELECT *FROM tbl_TestStats
WHERE CodeDate = '2016-12-03'
	AND CodeName = 'abc'
    
'Gather  (cost=1000.00..80484.88 rows=1 width=16) (actual time=347.355..347.496 rows=1 loops=1)'
'  Workers Planned: 2'
'  Workers Launched: 2'
'  -&gt;  Parallel Seq Scan on tbl_teststats  (cost=0.00..79484.77 rows=1 width=16) (actual time=278.702..340.557 rows=0 loops=3)'
'        Filter: ((codedate = '2016-12-03 00:00:00+05:30'::timestamp with time zone) AND (codename = 'abc'::text))'
'        Rows Removed by Filter: 2099520'
'Planning time: 0.168 ms'
'Execution time: 353.298 ms'</pre> </p>
<p><strong>Now, Create an Extended Statistics for correlated columns: </strong></p>
<pre class="crayon-plain-tag">CREATE STATISTICS Ext_Stat_tbl_TestStats (dependencies) ON CodeDate, CodeName 
FROM tbl_TestStats;</pre> </p>
<p><strong>Now, Execute ANALYZE:</strong></p>
<pre class="crayon-plain-tag">ANALYZE tbl_TestStats;</pre> </p>
<p><strong>Check execution plan for the same query:</strong><br />
Comparing to first result, you can find slightly performance improvement in the second result. </p>
<pre class="crayon-plain-tag">EXPLAIN ANALYZE
SELECT *FROM tbl_TestStats
WHERE CodeDate = '2016-12-03'
	AND CodeName = 'abc'
    
'Gather  (cost=1000.00..80484.86 rows=1 width=16) (actual time=150.732..311.567 rows=1 loops=1)'
'  Workers Planned: 2'
'  Workers Launched: 2'
'  -&gt;  Parallel Seq Scan on tbl_teststats  (cost=0.00..79484.76 rows=1 width=16) (actual time=251.261..304.857 rows=0 loops=3)'
'        Filter: ((codedate = '2016-12-03 00:00:00+05:30'::timestamp with time zone) AND (codename = 'abc'::text))'
'        Rows Removed by Filter: 2099520'
'Planning time: 0.167 ms'
'Execution time: 316.685 ms'</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: gp_stats_missing to get the list of pending ANALYZE of Tables</title>
		<link>https://www.dbrnd.com/2018/02/greenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing/</link>
					<comments>https://www.dbrnd.com/2018/02/greenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 04 Feb 2018 16:16:11 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[ANALYZE]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Database Statistics]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gp_stats_missing]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[smisize]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4424</guid>

					<description><![CDATA[In this post, I am sharing an important gp_toolkit view to finding a list of a table on which ANALYZE is required to be run in Greenplum Database Server. An ANALYZE command is used to update the object or database statistics information. The query planner always uses the statistics for building the execution plans. A [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&amp;linkname=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&amp;linkname=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&amp;linkname=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&amp;linkname=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&amp;linkname=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&amp;linkname=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fgreenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing%2F&#038;title=Greenplum%3A%20gp_stats_missing%20to%20get%20the%20list%20of%20pending%20ANALYZE%20of%20Tables" data-a2a-url="https://www.dbrnd.com/2018/02/greenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing/" data-a2a-title="Greenplum: gp_stats_missing to get the list of pending ANALYZE of Tables"></a></p><p>In this post, I am sharing an important gp_toolkit view to finding a list of a table on which ANALYZE is required to be run in Greenplum Database Server. </p>
<blockquote><p>An ANALYZE command is used to update the object or database statistics information. The query planner always uses the statistics for building the execution plans. </p></blockquote>
<blockquote><p>A gp_toolkit is an administrative schema of Greenplum Database server. It provides the list of various views to monitor the Greenplum server.</p></blockquote>
<blockquote><p>A gp_stats_missing is one of the views of a gp_toolkit schema which gives us a list of tables which may require an ANALYZE to be run. </p></blockquote>
<p><strong>Below is a query:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM gp_toolkit.gp_stats_missing;</pre> </p>
<p>After executing the above query, you can get the list of five columns. A column &#8220;smisize&#8221; is an important column to check the status of table statistics. </p>
<p>If it contains value &#8216;f&#8217;, a table does not have row count and row sizing statistics recorded in the system catalog, which indicates that the table needs to be analyzed. </p>
<p>The meaning of other columns like &#8220;simcols&#8221;: number of columns in the table, &#8220;simrecs&#8221;: number of rows in the table.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/02/greenplum-gp_stats_missing-to-get-the-list-of-pending-analyze-of-tables-gp_toolkit-gp_stats_missing/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Interview: What is the difference between AUTO_UPDATE_STATISTICS and AUTO_UPDATE_STATISTICS_ASYNC</title>
		<link>https://www.dbrnd.com/2017/08/sql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 03 Aug 2017 16:16:51 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Database Statistics]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5743</guid>

					<description><![CDATA[SQL Server Database Statistics is one of the important topics in the Query optimization. I already wrote a couple of articles on SQL Server Database Statistics. SQL Server: Enable Auto Create and Auto Update Statistics In the Interview of SQL DBA, If you say like you are also good in Query Optimization, there is 99% [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F08%2Fsql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async%2F&#038;title=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20AUTO_UPDATE_STATISTICS%20and%20AUTO_UPDATE_STATISTICS_ASYNC" data-a2a-url="https://www.dbrnd.com/2017/08/sql-server-interview-what-is-the-difference-between-auto_update_statistics-and-auto_update_statistics_async/" data-a2a-title="SQL Server Interview: What is the difference between AUTO_UPDATE_STATISTICS and AUTO_UPDATE_STATISTICS_ASYNC"></a></p><p>SQL Server Database Statistics is one of the important topics in the Query optimization. I already wrote a couple of articles on SQL Server Database Statistics. </p>
<blockquote data-secret="TB6z2j7iKI" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/12/sql-server-enable-auto-create-and-auto-update-statistics/">SQL Server: Enable Auto Create and Auto Update Statistics</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/12/sql-server-enable-auto-create-and-auto-update-statistics/embed/#?secret=TB6z2j7iKI" data-secret="TB6z2j7iKI" width="600" height="338" title="&#8220;SQL Server: Enable Auto Create and Auto Update Statistics&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>In the Interview of SQL DBA, If you say like you are also good in Query Optimization, there is 99% chance that interviewer asks questions on SQL Database Statistics.</p>
<p><strong>Why is Database Statistics important?</strong></p>
<blockquote><p>Simple answer &#8211; Query optimizer creates a query execution plan basis on Object Statistics information like record count, some real pages, page location. If statistics are not up to date, it generates the wrong query execution plan which will slow down the query performance. </p></blockquote>
<p><strong>How can we update Statistics automatically?</strong></p>
<blockquote><p>Statistics updates can be either synchronous (the default) or asynchronous.</p></blockquote>
<p><strong>AUTO_UPDATE_STATISTICS &#8211;  For synchronous update:</strong><br />
This is a synchronous option, and if it is running, a query has to wait for updated statistics. Updating statistics synchronously is the default behaviour, and once the statistics are updated, then the query will be executed. </p>
<pre class="crayon-plain-tag">ALTER DATABASE database_name SET AUTO_UPDATE_STATISTICS ON
GO</pre> </p>
<p><strong>AUTO_UPDATE_STATISTICS_ASYNC &#8211; For asynchronous update:</strong><br />
This is an asynchronous option, and if it is running, a query hasn&#8217;t required waiting for updated statistics because the query will be executed against the existing statistics. </p>
<p>In the background, at the same time database statistics update automatically using AUTO_UPDATE_STATISTICS_ASYNC option.<br />
Once the background statistics update process completes, the new query can use the newly updated database statistics. </p>
<pre class="crayon-plain-tag">ALTER DATABASE database_name SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE database_name SET AUTO_UPDATE_STATISTICS_ASYNC ON
GO</pre> </p>
<p><em>Please note: Before enabling the AUTO_UPDATE_STATISTICS_ASYNC option, Must have AUTO_UPDATE_STATISTICS enabled first</em></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
