<?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>Index statestics &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/index-statestics/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>Wed, 18 Jan 2017 20:42:22 +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: Script to find Index Size and Index Usage Statistics</title>
		<link>https://www.dbrnd.com/2017/01/postgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes/</link>
					<comments>https://www.dbrnd.com/2017/01/postgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 17 Jan 2017 20:39:12 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[BRIN Index]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[index duplicate]]></category>
		<category><![CDATA[Index statestics]]></category>
		<category><![CDATA[index usage]]></category>
		<category><![CDATA[missing index]]></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>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3840</guid>

					<description><![CDATA[In this post, I am sharing one script to find Index Usage Statistics of PostgreSQL Database. This is a very useful script for DBA to find out the usage of indexes and size of indexes which help them for performance tuning activity. For DBA, working with Indexes is always important tasks so I have already [&#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%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%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%2F2017%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%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%2F2017%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%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%2F2017%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%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%2F2017%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%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%2F2017%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%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%2F2017%2F01%2Fpostgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20Index%20Size%20and%20Index%20Usage%20Statistics" data-a2a-url="https://www.dbrnd.com/2017/01/postgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes/" data-a2a-title="PostgreSQL: Script to find Index Size and Index Usage Statistics"></a></p><p>In this post, I am sharing one script to find Index Usage Statistics of PostgreSQL Database.<br />
This is a very useful script for DBA to find out the usage of indexes and size of indexes which help them for performance tuning activity.</p>
<p>For DBA, working with Indexes is always important tasks so I have already shared a couple of articles on PostgreSQL Indexes. </p>
<blockquote><p><a href="https://www.dbrnd.com/2015/09/postgresql-script-to-find-the-unused-and-duplicate-index/" target="_blank">Duplicate Indexes:</a><br />
<a href="https://www.dbrnd.com/2015/10/postgresql-script-to-find-a-missing-indexes-of-the-schema/" target="_blank">Missing Indexes:</a><br />
<a href="https://www.dbrnd.com/2016/10/postgresql-how-we-can-create-index-on-expression-brin-btree-partial-index/" target="_blank">Expression Index:</a><br />
<a href="https://www.dbrnd.com/2016/08/postgresql-9-5-introduced-brin-block-range-index-with-detail-performance-test-report-on-6gb-table/" target="_blank">BRIN Index:</a></p></blockquote>
<p>In below script, You can also find occupied size of Indexes, Total tuple read and scan by Indexes. </p>
<pre class="crayon-plain-tag">SELECT
    pt.tablename AS TableName
    ,t.indexname AS IndexName
    ,pc.reltuples AS TotalRows
    ,pg_size_pretty(pg_relation_size(quote_ident(pt.tablename)::text)) AS TableSize
    ,pg_size_pretty(pg_relation_size(quote_ident(t.indexrelname)::text)) AS IndexSize
    ,t.idx_scan AS TotalNumberOfScan
    ,t.idx_tup_read AS TotalTupleRead
    ,t.idx_tup_fetch AS TotalTupleFetched
FROM pg_tables AS pt
LEFT OUTER JOIN pg_class AS pc 
	ON pt.tablename=pc.relname
LEFT OUTER JOIN
( 
	SELECT 
		pc.relname AS TableName
		,pc2.relname AS IndexName
		,psai.idx_scan
		,psai.idx_tup_read
		,psai.idx_tup_fetch
		,psai.indexrelname 
	FROM pg_index AS pi
	JOIN pg_class AS pc 
		ON pc.oid = pi.indrelid
	JOIN pg_class AS pc2 
		ON pc2.oid = pi.indexrelid
	JOIN pg_stat_all_indexes AS psai 
		ON pi.indexrelid = psai.indexrelid 
)AS T
    ON pt.tablename = T.TableName
WHERE pt.schemaname='public'
ORDER BY 1;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/01/postgresql-script-to-find-index-size-index-usage-statistics-of-a-database-pg_stat_all_indexes/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
