<?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>VACUUM FULL &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/vacuum-full/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>Mon, 26 Mar 2018 07:50:42 +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 check the status of AutoVacuum for all Tables</title>
		<link>https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/</link>
					<comments>https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 30 Mar 2018 16:16:01 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[ANALYZE]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[AUTO VACUUM]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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[VACUUM]]></category>
		<category><![CDATA[VACUUM FULL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7290</guid>

					<description><![CDATA[In this post, I am sharing a script for checking the status of AutoVacuum for all the PostgreSQL Tables. If you don&#8217;t know about the MVCC architecture, you must visit the below article. Because of MVCC, we have to work on dead tuples which are generated by transactions in PostgreSQL. What is Multi Version Concurrency [&#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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%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%2F03%2Fpostgresql-script-to-check-the-status-of-autovacuum-for-all-tables%2F&#038;title=PostgreSQL%3A%20Script%20to%20check%20the%20status%20of%20AutoVacuum%20for%20all%20Tables" data-a2a-url="https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/" data-a2a-title="PostgreSQL: Script to check the status of AutoVacuum for all Tables"></a></p><p>In this post, I am sharing a script for checking the status of AutoVacuum for all the PostgreSQL Tables. </p>
<p>If you don&#8217;t know about the MVCC architecture, you must visit the below article. Because of MVCC, we have to work on dead tuples which are generated by transactions in PostgreSQL. </p>
<blockquote class="wp-embedded-content" data-secret="JhjxG59FPW"><p><a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/">What is Multi Version Concurrency Control (MVCC)</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/embed/#?secret=JhjxG59FPW" data-secret="JhjxG59FPW" width="600" height="338" title="&#8220;What is Multi Version Concurrency Control (MVCC)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>You can configure auto-vacuum on tables, but periodically you should check the status of it. Use below script for checking the status of Autovacuum. </p>
<blockquote class="wp-embedded-content" data-secret="HyZBhFsEqV"><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 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=HyZBhFsEqV" data-secret="HyZBhFsEqV" 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>
<blockquote class="wp-embedded-content" data-secret="gCeWbfwdsz"><p><a href="https://www.dbrnd.com/2016/08/postgresql-force-autovacuum-for-running-aggressive-improve-performance-of-autovacuum-frequent-run/">PostgreSQL: Force Autovacuum for running Aggressive</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-force-autovacuum-for-running-aggressive-improve-performance-of-autovacuum-frequent-run/embed/#?secret=gCeWbfwdsz" data-secret="gCeWbfwdsz" width="600" height="338" title="&#8220;PostgreSQL: Force Autovacuum for running Aggressive&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<pre class="crayon-plain-tag">SELECT 
    schemaname
    ,relname
    ,n_live_tup
    ,n_dead_tup
    ,last_autovacuum
FROM pg_stat_all_tables
ORDER BY n_dead_tup
    /(n_live_tup
      * current_setting('autovacuum_vacuum_scale_factor')::float8
      + current_setting('autovacuum_vacuum_threshold')::float8)
     DESC</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/03/postgresql-script-to-check-the-status-of-autovacuum-for-all-tables/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Greenplum: gp_bloat_diag to get the list of pending VACUUM of Tables</title>
		<link>https://www.dbrnd.com/2018/02/greenplum-gp_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 05 Feb 2018 16:16:23 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[ACCESS EXCLUSIVE LOCK]]></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[gp_bloat_diag]]></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[VACUUM]]></category>
		<category><![CDATA[VACUUM FULL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4425</guid>

					<description><![CDATA[In this post, I am sharing an important gp_toolkit view to finding a list of a table on which VACUUM is required to be run in Greenplum Database Server. Greenplum is based on PostgreSQL 8.2 and MVCC architecture. It generates dead tuples at every UPDATE and DELETE which is a fragmentation in the form of [&#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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&amp;linkname=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&amp;linkname=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&amp;linkname=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&amp;linkname=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&amp;linkname=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&amp;linkname=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%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_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance%2F&#038;title=Greenplum%3A%20gp_bloat_diag%20to%20get%20the%20list%20of%20pending%20VACUUM%20of%20Tables" data-a2a-url="https://www.dbrnd.com/2018/02/greenplum-gp_bloat_diag-to-get-the-list-of-pending-vacuum-of-tables-remove-fragmentation-improve-performance/" data-a2a-title="Greenplum: gp_bloat_diag to get the list of pending VACUUM 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 VACUUM is required to be run in Greenplum Database Server. </p>
<blockquote><p>Greenplum is based on PostgreSQL 8.2 and MVCC architecture. It generates dead tuples at every UPDATE and DELETE which is a fragmentation in the form of dead tuples which we can remove by executing a VACUUM/VACUUM FULL command. </p></blockquote>
<blockquote class="wp-embedded-content" data-secret="MOZC5oUpBb"><p><a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/">What is Multi Version Concurrency Control (MVCC)</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/embed/#?secret=MOZC5oUpBb" data-secret="MOZC5oUpBb" width="600" height="338" title="&#8220;What is Multi Version Concurrency Control (MVCC)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<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>
<p>A gp_bloat_diag is one of the views of a gp_toolkit schema which gives us a list of tables which may require a VACUUM to be run. </p>
<p>It returns the actual number of pages and the expected number of pages. If a count of an actual number of pages is greater than expected number of pages, that table requires VACUUM. </p>
<p>If you want to re-use the wasted space of table, execute VACUUM FULL on it which requires ACCESS EXCLUSIVE LOCK on a table because it re-writes all the data pages from the scratch.</p>
<p>If you execute only VACUUM, you cannot reclaims the free space of table.<br />
You must execute ANALYZE after the execution of VACUUM/VACUUM FULL for updating database statistics. </p>
<p><strong>Below is a query:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM gp_toolkit.gp_bloat_diag;</pre> </p>
<p>After executing the above query, you can get the list of six columns. The important columns are &#8220;bdirelpages&#8221; and &#8220;bdiexppages&#8221; means real pages and expected pages. </p>
<p>If you find your table in the result set, your table requires VACUUM/VACUUM FULL. </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to find total Live Tuples and Dead Tuples (Row) of a Table</title>
		<link>https://www.dbrnd.com/2016/10/postgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance/</link>
					<comments>https://www.dbrnd.com/2016/10/postgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 04 Oct 2016 16:16:17 +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[dead tuples]]></category>
		<category><![CDATA[live tuples]]></category>
		<category><![CDATA[Multi version concurrency control]]></category>
		<category><![CDATA[MVCC]]></category>
		<category><![CDATA[pg_class]]></category>
		<category><![CDATA[pg_stat_get_dead_tuples()]]></category>
		<category><![CDATA[pg_stat_get_live_tuples()]]></category>
		<category><![CDATA[pg_stat_user_tables]]></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[VACUUM]]></category>
		<category><![CDATA[VACUUM FULL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3701</guid>

					<description><![CDATA[This is one of the very important post for all PostgreSQL Database Professionals. In this post, I am sharing a small, but very powerful script to know about the Live Tuples (Rows) and Dead Tuples (Rows) of the PostgreSQL Object like: Tables and Indexes. If you don&#8217;t know about the MVCC (Multi Version Concurrency Control), [&#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%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%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%2F2016%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%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%2F2016%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%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%2F2016%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%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%2F2016%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%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%2F2016%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%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%2F2016%2F10%2Fpostgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20total%20Live%20Tuples%20and%20Dead%20Tuples%20%28Row%29%20of%20a%20Table" data-a2a-url="https://www.dbrnd.com/2016/10/postgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance/" data-a2a-title="PostgreSQL: Script to find total Live Tuples and Dead Tuples (Row) of a Table"></a></p><p>This is one of the very important post for all PostgreSQL Database Professionals. </p>
<blockquote><p>In this post, I am sharing a small, but very powerful script to know about the Live Tuples (Rows) and Dead Tuples (Rows) of the PostgreSQL Object like: Tables and Indexes. </p></blockquote>
<p>If you don&#8217;t know about the MVCC (Multi Version Concurrency Control), Please visit this article. </p>
<blockquote data-secret="xsJ3wB5C2a" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/">What is Multi Version Concurrency Control (MVCC)</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/embed/#?secret=xsJ3wB5C2a" data-secret="xsJ3wB5C2a" width="600" height="338" title="&#8220;What is Multi Version Concurrency Control (MVCC)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote><p>PostgreSQL is based on MVCC Architecture. </p>
<p>In MVCC Architecture, When you update or delete any row, Internally It creates the new row and mark old row as unused. </p>
<p>This kind of data, we call as Dead Tuples or Dead Rows. (We can also say like, This is an internal fragmentation).
</p></blockquote>
<p>Periodically, We should find dead rows of the object and we should remove it using VACUUM techniques of PostgreSQL.<br />
By this way, we can increase the overall performance of PostgreSQL Database Server. </p>
<blockquote data-secret="LxJHZJGjlB" class="wp-embedded-content"><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=LxJHZJGjlB" data-secret="LxJHZJGjlB" 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>
<p><strong>Find out Live Tuples or Dead Tuples using two different scripts. </strong></p>
<p><strong>Using system function and pg_class:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	relname AS ObjectName
	,pg_stat_get_live_tuples(c.oid) AS LiveTuples
	,pg_stat_get_dead_tuples(c.oid) AS DeadTuples
FROM pg_class c;</pre> </p>
<p><strong>Using pg_stat_user_tables:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	relname AS TableName
	,n_live_tup AS LiveTuples
	,n_dead_tup AS DeadTuples
FROM pg_stat_user_tables;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/10/postgresql-script-to-find-total-live-tuples-and-dead-tuples-row-of-a-table-execute-vacuum-remove-fragmentation-improve-performance/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Execute VACUUM FULL without Disk Space</title>
		<link>https://www.dbrnd.com/2015/11/postgresql-execute-vacuum-full-without-disk-space/</link>
					<comments>https://www.dbrnd.com/2015/11/postgresql-execute-vacuum-full-without-disk-space/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 22 Nov 2015 17:22:57 +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[MVCC]]></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[VACUUM]]></category>
		<category><![CDATA[VACUUM FULL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1065</guid>

					<description><![CDATA[How to perform VACUUM FULL without disk space? The above question is common for all PostgreSQL DBA. This is really a very important topic that I am going to discuss in this post. We require VACUUM and VACUUM FULL in PostgreSQL because of MVCC Architecture. You can visit this article for MVCC: Postgres VACUUM FULL [&#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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&amp;linkname=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" 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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&amp;linkname=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" 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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&amp;linkname=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" 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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&amp;linkname=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" 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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&amp;linkname=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" 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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&amp;linkname=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" 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%2F11%2Fpostgresql-execute-vacuum-full-without-disk-space%2F&#038;title=PostgreSQL%3A%20Execute%20VACUUM%20FULL%20without%20Disk%20Space" data-a2a-url="https://www.dbrnd.com/2015/11/postgresql-execute-vacuum-full-without-disk-space/" data-a2a-title="PostgreSQL: Execute VACUUM FULL without Disk Space"></a></p><p><strong>How to perform VACUUM FULL without disk space?</strong></p>
<p>The above question is common for all PostgreSQL DBA. This is really a very important topic that I am going to discuss in this post.</p>
<p>We require VACUUM and VACUUM FULL in PostgreSQL because of MVCC Architecture.<br />
<a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/" target="_blank">You can visit this article for MVCC:</a></p>
<blockquote><p>Postgres VACUUM FULL reclaims all free space released by VACUUM by removing dead rows physically.</p>
<p>This method also requires extra disk space, since it writes a new copy of the table and doesn&#8217;t release the old copy until the operation is complete.</p></blockquote>
<p>In one of our Postgres Database Server, we require VACUUM FULL on one table, and this table size is 13GB, and we don&#8217;t have enough free space on hard-disk.</p>
<p><strong>I worked around this problem and created one of the best solutions to resolve this problem. </strong></p>
<blockquote><p>To solve this problem, we need additional storage like any other network drive or portable hard disk.<br />
Please do not forget that VACUUM FULL requires an exclusive lock on the table so during this operation your table cannot be accessible.</p></blockquote>
<p>Now, add new hard disk and make it as table-space.</p>
<p><strong>Create a new tablespace:</strong></p><pre class="crayon-plain-tag">CREATE TABLESPACE temptablespace LOCATION '/path/../';</pre><p>
<strong>Check your table current tablespace:</strong></p><pre class="crayon-plain-tag">SELECT tablespace FROM pg_tables WHERE tablename = 'mybigtable';</pre><p>
If it is NULL, it has a default tablespace.</p>
<p><strong>Move table to new tablespace:</strong><br />
<pre class="crayon-plain-tag">ALTER TABLE mybigtable SET TABLESPACE temptablespace;</pre>
<p><strong>Perform VACUUM FULL:</strong><br />
<pre class="crayon-plain-tag">VACUUM FULL mybigtable;</pre>
<p><strong>Move table to old tablespace:(moving to pg_default)</strong><br />
<pre class="crayon-plain-tag">ALTER TABLE mybigtable SET TABLESPACE pg_default;</pre>
<p><strong>Drop that temp table space:</strong><br />
<pre class="crayon-plain-tag">DROP TABLESPACE temptablespace;</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/11/postgresql-execute-vacuum-full-without-disk-space/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE</title>
		<link>https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/</link>
					<comments>https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 21 Nov 2015 17:47:18 +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[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[VACUUM]]></category>
		<category><![CDATA[VACUUM FULL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1081</guid>

					<description><![CDATA[VACUUM, VACUUM FULL and ANALYZE: These are the maintenance related commands of PostgreSQL which requires frequent execution because PostgreSQL based on MVCC architecture where every UPDATE and DELETE generates dead rows or dead tuples as an internal fragmentation. If you don&#8217;t about the MVCC, you must visit the below article. What is MVCC? VACUUM: VACUUM [&#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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&amp;linkname=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" 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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&amp;linkname=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" 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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&amp;linkname=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" 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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&amp;linkname=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" 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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&amp;linkname=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" 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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&amp;linkname=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" 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%2F11%2Fpostgresql-short-note-on-vacuum-vacuum-full-and-analyze%2F&#038;title=PostgreSQL%3A%20Short%20note%20on%20VACUUM%2C%20VACUUM%20FULL%20and%20ANALYZE" data-a2a-url="https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/" data-a2a-title="PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE"></a></p><p><strong>VACUUM, VACUUM FULL and ANALYZE:</strong> These are the maintenance related commands of PostgreSQL which requires frequent execution because PostgreSQL based on MVCC architecture where every UPDATE and DELETE generates dead rows or dead tuples as an internal fragmentation. </p>
<p>If you don&#8217;t about the MVCC, you must visit the below article.<br />
<a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/" target="_blank"><strong>What is MVCC?</strong></a></p>
<p><strong>VACUUM:</strong> </p>
<blockquote><p>VACUUM reclaims storage occupied by dead tuples.<br />
In the MCVV architecture tuples that deleted which is not physically remove. It presents in a disk until a VACUUM is done.</p>
<p>If you are executing frequent UPDATE/DELETE on your table, you must find the fragmentation and must execute VACUUM on it.<br />
VACUUM does not require an exclusive lock on the table.<br />
<strong>Syntax:</strong></p>
<pre class="crayon-plain-tag">VACUUM Table_Name;</pre> </p>
</blockquote>
<p><strong>VACUUM FULL:</strong></p>
<blockquote><p>
Whatever space reclaims by VACUUM that space might require to use for next storage.<br />
VACUUM FULL rewrites the entire table with data and releases all fragmented space of an old table.</p>
<p>We should avoid the VACUUM FULL because it shrinks the whole table and writes everything into the new disk block which requires more resources and disk space to complete this operation.</p>
<p>If you find a huge number of dead rows, you should execute VACUUM FULL on that table.<br />
VACUUM FULL requires an exclusive lock on the table and also require a free disk space as same as your table size.<br />
<strong>Syntax:</strong></p><pre class="crayon-plain-tag">VACUUM FULL Table_Name;</pre><p> </p>
</blockquote>
<p><strong>ANALYZE:</strong></p>
<blockquote><p>
After execution of VACUUM or VACUUM FULL, you must execute this command to update the statistics.<br />
ANALYZE updates all require statistics and stores the results in the pg_statistic system catalog. </p>
<p>The Query Planner uses this database statistics information to prepare an efficient query execution plan.<br />
You can also execute VACUUM ANALYZE, which executes the first VACUUM and then executes ANALYZE.<br />
<strong>Syntax:</strong></p>
<pre class="crayon-plain-tag">ANALYZE Table_Name;
VACUUM ANALYZE Table_Name;</pre> </p>
</blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
