<?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>pg_index &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/pg_index/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>Fri, 08 Dec 2017 04:49:47 +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 the Used space by TOAST Table</title>
		<link>https://www.dbrnd.com/2017/12/postgresql-script-to-find-the-used-space-by-toast-table/</link>
					<comments>https://www.dbrnd.com/2017/12/postgresql-script-to-find-the-used-space-by-toast-table/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 29 Dec 2017 16:16:27 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></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_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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[toast table]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6852</guid>

					<description><![CDATA[If you don&#8217;t know about the TOAST Table, please visit the below article. PostgreSQL: What is TOAST (The Oversized-Attribute Storage Technique) In this post, I am sharing a script to check the used space by the TOAST tables in the PostgreSQL. We should avoid the auto-creation of TOAST table which is not suitable for database [&#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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" 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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" 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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" 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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" 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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" 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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" 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%2F12%2Fpostgresql-script-to-find-the-used-space-by-toast-table%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20the%20Used%20space%20by%20TOAST%20Table" data-a2a-url="https://www.dbrnd.com/2017/12/postgresql-script-to-find-the-used-space-by-toast-table/" data-a2a-title="PostgreSQL: Script to find the Used space by TOAST Table"></a></p><p>If you don&#8217;t know about the TOAST Table, please visit the below article. </p>
<blockquote class="wp-embedded-content" data-secret="N0UPzzgQem"><p><a href="https://www.dbrnd.com/2016/10/postgresql-what-is-toast-the-oversized-attribute-storage-technique-exceed-8-kb-data-page-size-extended-storage/">PostgreSQL: What is TOAST (The Oversized-Attribute Storage Technique)</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/10/postgresql-what-is-toast-the-oversized-attribute-storage-technique-exceed-8-kb-data-page-size-extended-storage/embed/#?secret=N0UPzzgQem" data-secret="N0UPzzgQem" width="600" height="338" title="&#8220;PostgreSQL: What is TOAST (The Oversized-Attribute Storage Technique)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>In this post, I am sharing a script to check the used space by the TOAST tables in the PostgreSQL. </p>
<blockquote><p>We should avoid the auto-creation of TOAST table which is not suitable for database performance.<br />
Using below script, you can find the size and can take the appropriate decision on the biggest TOAST table of your database.</p></blockquote>
<p>Below script is returning two columns where relpages is a number of occupied pages by the TOAST table. (1 page = 8kb)</p>
<pre class="crayon-plain-tag">SELECT 
    relname
    ,relpages
FROM pg_class,
     (SELECT reltoastrelid
      FROM pg_class) AS ss
WHERE oid = ss.reltoastrelid OR
      oid = (SELECT indexrelid
             FROM pg_index
             WHERE indrelid = ss.reltoastrelid)
ORDER BY relname;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/12/postgresql-script-to-find-the-used-space-by-toast-table/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to find the unused and duplicate index</title>
		<link>https://www.dbrnd.com/2015/09/postgresql-script-to-find-the-unused-and-duplicate-index/</link>
					<comments>https://www.dbrnd.com/2015/09/postgresql-script-to-find-the-unused-and-duplicate-index/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 28 Sep 2015 18:47:28 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL 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[duplicate index]]></category>
		<category><![CDATA[pg_index]]></category>
		<category><![CDATA[pg_stat_user_indexes]]></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[unused index]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=739</guid>

					<description><![CDATA[As I am preparing important scripts for PostgreSQL DBA, so here I am also sharing one more important script to find the unused and duplicate index in PostgreSQL. The management and maintenance of database index is a day to day exercise for a Database Administrator, and unused index can create a performance issues for the [&#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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" 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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" 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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" 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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" 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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" 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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" 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%2F2015%2F09%2Fpostgresql-script-to-find-the-unused-and-duplicate-index%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20the%20unused%20and%20duplicate%20index" data-a2a-url="https://www.dbrnd.com/2015/09/postgresql-script-to-find-the-unused-and-duplicate-index/" data-a2a-title="PostgreSQL: Script to find the unused and duplicate index"></a></p><p>As I am preparing important scripts for PostgreSQL DBA, so here I am also sharing one more important script to find the unused and duplicate index in PostgreSQL.</p>
<p>The management and maintenance of database index is a day to day exercise for a Database Administrator, and unused index can create a performance issues for the whole database system.</p>
<blockquote><p>At every insert and update, the data of an index are also changing, and it requires some IO operations. Better to find unused index and drop it.</p></blockquote>
<p>Sometimes, I found that duplicate indexes on the same table, e.g. same table, same columns, same order of columns and created with a different name. Internally this will also impact to our database performance.</p>
<p>I am sharing two different scripts for finding the unused and duplicate index in PostgreSQL.</p>
<p><strong>Script to find the unused indexes in PostgreSQL:</strong></p>
<pre class="crayon-plain-tag">SELECT
	PSUI.indexrelid::regclass AS IndexName
	,PSUI.relid::regclass AS TableName
FROM pg_stat_user_indexes AS PSUI    
JOIN pg_index AS PI 
    ON PSUI.IndexRelid = PI.IndexRelid
WHERE PSUI.idx_scan = 0 
	AND PI.indisunique IS FALSE;</pre> </p>
<p><strong>Script to find the duplicate indexes in PostgreSQL:</strong></p>
<pre class="crayon-plain-tag">SELECT
    indrelid::regclass AS TableName
    ,array_agg(indexrelid::regclass) AS Indexes
FROM pg_index 
GROUP BY 
    indrelid
    ,indkey 
HAVING COUNT(*) &gt; 1;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/09/postgresql-script-to-find-the-unused-and-duplicate-index/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
