<?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>Statistics &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/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>Sun, 17 Dec 2017 20:08:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server 2014: Introduced DBCC CLONEDATABASE TO generate only Schema and Statistics</title>
		<link>https://www.dbrnd.com/2018/01/sql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 02 Jan 2018 16:16:21 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbcc]]></category>
		<category><![CDATA[DBCC CLONEDATABASE]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Query Store]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[SNAPSHOT]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4139</guid>

					<description><![CDATA[<div><img width="452" height="336" src="https://www.dbrnd.com/wp-content/uploads/2018/01/SQL-Server-Clone-Database.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQL Server Clone Database" decoding="async" fetchpriority="high" /></div>SQL Server 2014 introduced DBCC CLONEDATABASE for creating a blank database with only Schema and Statistics. SQL Server 2016 added support of the Query Store in DBCC CLONEDATABASE. This feature is very helpful in certain conditions. For example, Your production database size is around 800 GB, and You faced some performance related issues because the [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="452" height="336" src="https://www.dbrnd.com/wp-content/uploads/2018/01/SQL-Server-Clone-Database.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQL Server Clone Database" 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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&amp;linkname=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&amp;linkname=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&amp;linkname=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&amp;linkname=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&amp;linkname=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&amp;linkname=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%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%2F01%2Fsql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store%2F&#038;title=SQL%20Server%202014%3A%20Introduced%20DBCC%20CLONEDATABASE%20TO%20generate%20only%20Schema%20and%20Statistics" data-a2a-url="https://www.dbrnd.com/2018/01/sql-server-2014-introduced-dbcc-clonedatabase-to-generate-only-schema-statistics-query-store/" data-a2a-title="SQL Server 2014: Introduced DBCC CLONEDATABASE TO generate only Schema and Statistics"></a></p><p><em>SQL Server 2014 introduced DBCC CLONEDATABASE for creating a blank database with only Schema and Statistics.</p>
<p>SQL Server 2016 added support of the Query Store in DBCC CLONEDATABASE.</em></p>
<blockquote><p>
This feature is very helpful in certain conditions.<br />
For example, Your production database size is around 800 GB, and You faced some performance related issues because the problem of outdated Statistics or Indexes issue.</p></blockquote>
<blockquote><p>Now the situation is, you can do a test and trial in your Production Database, so DBA takes a copy of Production Database and restore it in different server for further investigation.</p></blockquote>
<blockquote><p>Do you think, this is the only one solution because Its require additional time and infrastructure.</p></blockquote>
<blockquote><p>In this kind of situation, you can use the DBCC CLONEDATABASE feature of SQL Server 2014.</p></blockquote>
<blockquote><p>It creates a blank database copy with the only Schema, Statistics and Query Store information. It is not copying the data, so it does not require any additional space.</p></blockquote>
<blockquote><p>You can find the same statistical information in the new clone database which generates the same execution plan for your investigation.</p>
<p>A Query Execution Plan is prepared to base on Database Statistics so If Database Statistics are same then you check your query execution plan without data.</p></blockquote>
<p>Once you are finished with your task with Clone Database, you can delete it.</p>
<p><strong>How internally SQL Server creates a Clone Database?</strong></p>
<blockquote><p>It validates the source database and acquires the shared lock on the source database</p>
<p>	It creates a snapshot of the source database (Include only: Schema, Statistics, Query Store)</p>
<p>	Create Clone Database and acquires an exclusive lock on it</p>
<p>	Copy the metadata, schema, statistics, query store information from the source database to clone database</p>
<p>	Release all locks from Clone Database</p></blockquote>
<p><strong>How to create a Clone Database?</strong></p>
<p>Use DBCC CLONEDATABASE command to create a Clone Database.<br />
<pre class="crayon-plain-tag">DBCC CLONEDATABASE (MyDatabase,MyDatabase_Clone);</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Performance Test &#8211; Problem of mismatched Column Data Type</title>
		<link>https://www.dbrnd.com/2017/07/sql-server-performance-test-problem-of-mismatched-column-data-type/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 16 Jul 2017 16:16:08 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Logical reads]]></category>
		<category><![CDATA[Physical Reads]]></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[Statistics]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5623</guid>

					<description><![CDATA[In this post, I am sharing performance test of the problem of mismatched column data type in SQL Server. The Database Designer is also defining a wrong mismatched column data type by giving different data types to the same column for many tables. For example, empid column -> assigned INT in tbl_emp table and -> [&#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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&amp;linkname=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" 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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&amp;linkname=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" 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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&amp;linkname=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" 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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&amp;linkname=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" 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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&amp;linkname=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" 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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&amp;linkname=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" 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%2F07%2Fsql-server-performance-test-problem-of-mismatched-column-data-type%2F&#038;title=SQL%20Server%3A%20Performance%20Test%20%E2%80%93%20Problem%20of%20mismatched%20Column%20Data%20Type" data-a2a-url="https://www.dbrnd.com/2017/07/sql-server-performance-test-problem-of-mismatched-column-data-type/" data-a2a-title="SQL Server: Performance Test – Problem of mismatched Column Data Type"></a></p><p>In this post, I am sharing performance test of the problem of mismatched column data type in SQL Server. </p>
<p>The Database Designer is also defining a wrong mismatched column data type by giving different data types to the same column for many tables. </p>
<blockquote><p>For example, empid column -> assigned INT in tbl_emp table and -> assigned BIGINT in tbl_dept table. Because of this kind of problem, your query will execute slowly, and it requires implicit data conversion for each record. </p></blockquote>
<blockquote><p>Another example is, your column data type is VARCHAR, and you are checking N&#8217;DATA in WHERE clause which is NVARCHAR, so this is also required implicit data conversion. </p></blockquote>
<p><strong>Please check below full demonstration and, test it yourself:</strong></p>
<p><strong>Create a sample table, where [id] column type is varchar:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_DiffDataTypes 
(	id varchar(25)
	,name VARCHAR(25)
	,constraint pk_tbl_DiffDataTypes_id primary key (id)
)
GO</pre> </p>
<p><strong>Insert few dummy records:</strong></p>
<pre class="crayon-plain-tag">DECLARE @i INT,@max INT
SET @i =1 
SET @max =99999
WHILE @i&lt;=@max
BEGIN
   INSERT INTO tbl_DiffDataTypes VALUES(@i,'dbrnd.com')
   SET @i=@i+1
END</pre> </p>
<p><strong>Please enable STATISTICS:</strong></p>
<pre class="crayon-plain-tag">SET STATISTICS IO ON
SET STATISTICS TIME ON</pre> </p>
<p><strong>Test WHERE filter with VARCHAR value: (Only 3 logical reads)</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_DiffDataTypes WHERE id = '1'</pre> </p>
<p><strong>Result of Statistics:</strong></p>
<pre class="crayon-plain-tag">Table 'tbl_DiffDataTypes'. Scan count 0, logical reads 3, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.</pre> </p>
<p><strong>Test WHERE filter with NVARCHAR value: (62 logical reads)</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_DiffDataTypes WHERE id = N'1'</pre> </p>
<p><strong>Result of Statistics:</strong></p>
<pre class="crayon-plain-tag">Table 'tbl_DiffDataTypes'. Scan count 1, logical reads 62, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.</pre> </p>
<p><strong>Test WHERE filter with INTEGER value: (621 logical reads)</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_DiffDataTypes WHERE id = 1</pre> </p>
<p><strong>Result of Statistics:</strong></p>
<pre class="crayon-plain-tag">Table 'tbl_DiffDataTypes'. Scan count 1, logical reads 621, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to find the size and usage statistics of Indexes</title>
		<link>https://www.dbrnd.com/2017/06/greenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes/</link>
					<comments>https://www.dbrnd.com/2017/06/greenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 08 Jun 2017 16:16:56 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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[index usage]]></category>
		<category><![CDATA[pg_stat_all_indexes]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[Statistics]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5373</guid>

					<description><![CDATA[In this post, I am sharing a script to find the size and usage statistics of Greenplum Indexes. Having the complete knowledge of our database indexes is imperative. We should check the size and usage of indexes. Recently, I started my work with Greenplum which based on PostgreSQL 8.2, so I am sharing a script [&#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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" 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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" 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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" 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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" 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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" 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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" 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%2F06%2Fgreenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes%2F&#038;title=Greenplum%3A%20Script%20to%20find%20the%20size%20and%20usage%20statistics%20of%20Indexes" data-a2a-url="https://www.dbrnd.com/2017/06/greenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes/" data-a2a-title="Greenplum: Script to find the size and usage statistics of Indexes"></a></p><p>In this post, I am sharing a script to find the size and usage statistics of Greenplum Indexes. Having the complete knowledge of our database indexes is imperative. We should check the size and usage of indexes.</p>
<p>Recently, I started my work with Greenplum which based on PostgreSQL 8.2, so I am sharing a script to check index usage in Greenplum.</p>
<pre class="crayon-plain-tag">SELECT
    t.schemaname AS schema_name
    ,t.tablename AS table_name
    ,indexname AS index_name
    ,c.reltuples AS num_rows
    ,pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size
    ,pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size
    ,CASE WHEN indisunique THEN 'Y'
       ELSE 'N'
    END AS UNIQUE
    ,idx_scan AS number_of_scans
    ,idx_tup_read AS tuples_read
    ,idx_tup_fetch AS tuples_fetched
FROM pg_tables t
LEFT OUTER JOIN pg_class c ON t.tablename=c.relname
LEFT OUTER JOIN
( SELECT c.relname AS ctablename, ipg.relname AS indexname, x.indnatts AS number_of_columns, idx_scan, idx_tup_read, idx_tup_fetch, indexrelname, indisunique FROM pg_index x
   JOIN pg_class c ON c.oid = x.indrelid
   JOIN pg_class ipg ON ipg.oid = x.indexrelid
   JOIN pg_stat_all_indexes psai ON x.indexrelid = psai.indexrelid )
AS t1
ON t.tablename = t1.ctablename;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/06/greenplum-script-to-find-the-size-and-usage-statistics-of-indexes-pg_stat_all_indexes/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Script to find Outdated Index Statistics</title>
		<link>https://www.dbrnd.com/2016/12/sql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 21 Dec 2016 03:46:22 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[Index Statistics]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[update statistics]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4060</guid>

					<description><![CDATA[In this post, I am sharing one script to find Outdated Index Statistics of SQL Server. Database Statistics are playing the main role to prepare a best query execution plan because Query Optimizer reads the Object Statistics and takes the decision accordingly. SQL Server Statistics stores information like: object meta-data, location information, number of records. [&#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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&#038;title=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" data-a2a-url="https://www.dbrnd.com/2016/12/sql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance/" data-a2a-title="SQL Server: Script to find Outdated Index Statistics"></a></p><p>In this post, I am sharing one script to find Outdated Index Statistics of SQL Server. </p>
<blockquote><p>Database Statistics are playing the main role to prepare a best query execution plan because Query Optimizer reads the Object Statistics and takes the decision accordingly.</p></blockquote>
<blockquote><p>SQL Server Statistics stores information like: object meta-data, location information, number of records.<br />
If your Object Statistics are not updated, It impacts your query performance so You should find outdated statistics and periodically, you should update the statistics data.</p></blockquote>
<blockquote class="wp-embedded-content" data-secret="wUbwAj9WoM"><p><a href="https://www.dbrnd.com/2016/11/sql-serverwarning-in-query-execution-plan-operator-used-tempdb-to-spill-data-during-execution-with-spill-level-2-sql-update-statistics-sp_updatestats/">SQL Server:Warning in Query Execution Plan, &#8220;Operator used tempdb to spill data during execution with spill level 2&#8221;</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/11/sql-serverwarning-in-query-execution-plan-operator-used-tempdb-to-spill-data-during-execution-with-spill-level-2-sql-update-statistics-sp_updatestats/embed/#?secret=wUbwAj9WoM" data-secret="wUbwAj9WoM" width="600" height="338" title="&#8220;SQL Server:Warning in Query Execution Plan, &#8220;Operator used tempdb to spill data during execution with spill level 2&#8221;&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Script to find Outdated Index Statistics Information:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	OBJECT_NAME(id)
	,name
	,STATS_DATE(id, indid)
	,rowmodctr
FROM sys.sysindexes
WHERE STATS_DATE(id, indid)&lt;=DATEADD(DAY,-1,GETDATE()) 
AND rowmodctr&gt;0 
AND id IN (SELECT object_id FROM sys.tables)
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: The Importance of Statistics and Why It is important</title>
		<link>https://www.dbrnd.com/2016/12/sql-server-the-importance-of-statistics-and-why-it-is-important/</link>
					<comments>https://www.dbrnd.com/2016/12/sql-server-the-importance-of-statistics-and-why-it-is-important/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 15 Dec 2016 20:08:30 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2511</guid>

					<description><![CDATA[Statistics for query optimization are objects that contain statistical information about the distribution of values in one or more columns of a table or indexed view. The query optimizer of Microsoft SQL Server is a cost-based optimizer. One of the most important of is the information about the number of rows that are expected to [&#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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&amp;linkname=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" 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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&amp;linkname=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" 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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&amp;linkname=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" 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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&amp;linkname=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" 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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&amp;linkname=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" 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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&amp;linkname=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" 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%2F2016%2F12%2Fsql-server-the-importance-of-statistics-and-why-it-is-important%2F&#038;title=SQL%20Server%3A%20The%20Importance%20of%20Statistics%20and%20Why%20It%20is%20important" data-a2a-url="https://www.dbrnd.com/2016/12/sql-server-the-importance-of-statistics-and-why-it-is-important/" data-a2a-title="SQL Server: The Importance of Statistics and Why It is important"></a></p><p><em>Statistics for query optimization are objects that contain statistical information about the distribution of values in one or more columns of a table or indexed view.</em></p>
<blockquote><p>The query optimizer of Microsoft SQL Server is a cost-based optimizer.<br />
One of the most important of is the information about the number of rows that are expected to be returned when the query is executed. This information is gleaned from what is called Statistics.
</p></blockquote>
<blockquote><p>If statistics are not accurate enough, the query optimizer of Microsoft SQL Server may choose an inappropriate execution plan because of overestimates the number of records.</p></blockquote>
<blockquote><p>When AUTO_CREATE_STATISTICS is on, query optimizer creates statistics for single columns and also query optimizer creates statistics for indexes on tables or views when the index is created. </p></blockquote>
<blockquote><p>If an error or other event prevents the query optimizer from creating statistics, the query optimizer creates the query plan without using statistics. The query optimizer marks the statistics as missing and attempts to regenerate the statistics the next time the query is executed.</p></blockquote>
<p><strong>Statistics updates can be either synchronous (the default) or asynchronous: </strong></p>
<blockquote><p>With synchronous statistics updates, queries always compile and execute with up-to-date statistics.<br />
When statistics are out-of-date, the query optimizer waits for updated statistics before compiling and executing the query.
</p></blockquote>
<blockquote><p>With asynchronous statistics updates, queries compile with existing statistics even if the existing statistics are out-of-date.</p></blockquote>
<blockquote><p>Your query response times might be more predictable with asynchronous statistics updates than with synchronous statistics updates because the query optimizer can execute incoming queries without waiting for up-to-date statistics.</p></blockquote>
<p><em>The query optimizer determines when statistics might be out-of-date and then updates them when they are needed for a query plan.<br />
In some cases you can improve the query plan by updating Statistics manually using sp_updatestats.<br />
You can also set AUTO_UPDATE_STATISTICS is on.</em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/12/sql-server-the-importance-of-statistics-and-why-it-is-important/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Important Statistics Table, Used by the Query Planner</title>
		<link>https://www.dbrnd.com/2016/09/postgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 04 Sep 2016 12:55:17 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[ANALYZE]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[pg_class]]></category>
		<category><![CDATA[pg_stats]]></category>
		<category><![CDATA[planner]]></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 Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[query optimzer]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[VACUUM]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3585</guid>

					<description><![CDATA[In any RDBMS system, Different type of Statistics is very important for Query Optimizer and Planner to choose and generate the best Query Execution Plan. PostgreSQL Database Server also managing different types of Statistic which are used by the Query Optimizer to generate the best Query Execution Plan. Statistical data should be updated, Why? For [&#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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" 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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" 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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" 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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" 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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" 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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" 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%2F2016%2F09%2Fpostgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze%2F&#038;title=PostgreSQL%3A%20Important%20Statistics%20Table%2C%20Used%20by%20the%20Query%20Planner" data-a2a-url="https://www.dbrnd.com/2016/09/postgresql-important-statistics-table-used-by-the-query-planner-pg_class-pg_stats-vacuum-analyze/" data-a2a-title="PostgreSQL: Important Statistics Table, Used by the Query Planner"></a></p><p>In any RDBMS system, Different type of Statistics is very important for Query Optimizer and Planner to choose and generate the best Query Execution Plan. </p>
<blockquote><p>PostgreSQL Database Server also managing different types of Statistic which are used by the Query Optimizer to generate the best Query Execution Plan. </p></blockquote>
<p><strong>Statistical data should be updated, Why?</strong><br />
For Example, </p>
<blockquote><p>We have one table with 100000 rows, but table statistic data are not updated and showing only 1000 tuples information. </p></blockquote>
<blockquote><p>Query optimizer always looks into Statistic tables, It never looks into direct table files. </p></blockquote>
<blockquote><p>So in this situation, It generates the wrong Query Execution Plan because It has only 1000 rows information, but actually there are 100000 rows. </p></blockquote>
<p>PostgreSQL Database Server is mainly using two Statistical Table. </p>
<pre class="crayon-plain-tag">SELECT *FROM pg_class;
SELECT *FROM pg_stats;</pre> </p>
<blockquote><p>You can also query these tables and can find information about Tables, Indexes, Pages and others. </p></blockquote>
<blockquote><p>When you look into table pg_class, you can find &#8220;reltuples&#8221; column. You can compare this column value with your actual table record count. </p></blockquote>
<blockquote><p>If you find any mismatch, for that table statistic information is not updated. </p></blockquote>
<p><strong>Execute Analyze command:</strong></p>
<blockquote><p>When you find that Statistical information is not updated, you can execute the ANALYZE command on the Database or Table.<br />
After executing the ANALYZE command, It updates all require statistics.
</p></blockquote>
<blockquote class="wp-embedded-content" data-secret="es4VwJnXrq"><p><a href="https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/">PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/embed/#?secret=es4VwJnXrq" data-secret="es4VwJnXrq" width="600" height="338" title="&#8220;PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
