<?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>free space &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/free-space/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>Thu, 22 Dec 2016 19:23:09 +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: How to check Table Fragmentation using pgstattuple module</title>
		<link>https://www.dbrnd.com/2016/12/postgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze/</link>
					<comments>https://www.dbrnd.com/2016/12/postgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 22 Dec 2016 19:23:09 +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 tuple]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[free space]]></category>
		<category><![CDATA[live tuple]]></category>
		<category><![CDATA[pgstattuple]]></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=4158</guid>

					<description><![CDATA[This is very important task for PostgreSQL DBA to check the fragmentation level of Table. Please do not forget about that the PostgreSQL is based on MVCC architecture. Which is good in one way, but bad in another way. Using below article, You must read about MVCC and also access other related articles. What is [&#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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" 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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" 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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" 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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" 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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" 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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&amp;linkname=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" 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%2Fpostgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze%2F&#038;title=PostgreSQL%3A%20How%20to%20check%20Table%20Fragmentation%20using%20pgstattuple%20module" data-a2a-url="https://www.dbrnd.com/2016/12/postgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze/" data-a2a-title="PostgreSQL: How to check Table Fragmentation using pgstattuple module"></a></p><p>This is very important task for PostgreSQL DBA to check the fragmentation level of Table.<img fetchpriority="high" decoding="async" class="alignright wp-image-4163 size-medium" title="postgresql fragmentation" src="https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-300x200.jpg" alt="postgresql fragmentation" width="300" height="200" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-300x200.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-150x100.jpg 150w, https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation.jpg 600w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<blockquote><p>Please do not forget about that the PostgreSQL is based on MVCC architecture. Which is good in one way, but bad in another way.</p>
<p>Using below article, You must read about MVCC and also access other related articles.</p></blockquote>
<blockquote data-secret="rBWgG1BnSb" 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 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=rBWgG1BnSb" data-secret="rBWgG1BnSb" 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 data-secret="C0qTcsvCip" 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 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=C0qTcsvCip" data-secret="C0qTcsvCip" 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 data-secret="52Q5WkuxDw" class="wp-embedded-content"><p><a href="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/">PostgreSQL: Script to find total Live Tuples and Dead Tuples (Row) of a Table</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="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/embed/#?secret=52Q5WkuxDw" data-secret="52Q5WkuxDw" width="600" height="338" title="&#8220;PostgreSQL: Script to find total Live Tuples and Dead Tuples (Row) of a Table&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote><p>PostgreSQL provides pgstattuple module to get all tuples information of a Table. You can find information like live_tuple, dead_tuple, free_space and other.</p></blockquote>
<blockquote><p>Using this information you can find fragmentation of table which you can remove using VACUUM / VACUUM FULL command.</p></blockquote>
<p>You must install the pgstattuple to find tuples related information. You can also use pgstatindex() to find information related to indexes.</p>
<p><strong>Load pgstattuple module:</strong><br />
<pre class="crayon-plain-tag">CREATE EXTENSION pgstattuple;</pre>
<strong>Create one sample table:</strong><br />
CREATE TABLE tbl_ItemTransactions<br />
<pre class="crayon-plain-tag">(
     TranID SERIAL
     ,TransactionDate TIMESTAMPTZ
     ,TransactionName TEXT
 );</pre>
<strong>Insert few millions of data:</strong><br />
<pre class="crayon-plain-tag">INSERT INTO tbl_ItemTransactions 
(TransactionDate, TransactionName)
SELECT x, 'dbrnd' 
FROM generate_series('2014-01-01 00:00:00'::timestamptz, '2016-08-01 00:00:00'::timestamptz,'2 seconds'::interval) a(x);</pre>
<strong>Check the tuple information using pgstattuple:</strong><br />
<pre class="crayon-plain-tag">SELECT *FROM pgstattuple('public.tbl_itemtransactions');</pre>
<strong>The Result:</strong><br />
<pre class="crayon-plain-tag">table_len          | 2125627392
tuple_count        | 40737601
tuple_len          | 1873929646
tuple_percent      | 88.16
dead_tuple_count   | 45
dead_tuple_len     | 7787
dead_tuple_percent | 0.88
free_space         | 9923
free_percent       | 1.96</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/12/postgresql-how-to-check-table-fragmentation-using-pgstattuple-module-remove-dead-tuple-vacuum-analyze/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
