<?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>large column &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/large-column/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, 21 Aug 2016 14:27:16 +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: Optimized way to populate new Column (UUID) in a Large Table</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 21 Aug 2016 14:27:16 +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[large column]]></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[Universally Unique Identifier]]></category>
		<category><![CDATA[UUID]]></category>
		<category><![CDATA[UUID Data type]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3547</guid>

					<description><![CDATA[The default nature of PostgreSQL is based on MVCC architecture which managed by different type of ROW versions. You can read more about MVCC, What is Multi Version Concurrency Control (MVCC) Why I have started this article with MVCC because whenever we update data into the table, it creates a new record and marked 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%2F2016%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&amp;linkname=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%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%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&amp;linkname=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%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%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&amp;linkname=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%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%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&amp;linkname=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%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%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&amp;linkname=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%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%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&amp;linkname=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%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%2F08%2Fpostgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier%2F&#038;title=PostgreSQL%3A%20Optimized%20way%20to%20populate%20new%20Column%20%28UUID%29%20in%20a%20Large%20Table" data-a2a-url="https://www.dbrnd.com/2016/08/postgresql-optimized-way-to-populate-new-large-column-in-a-table-uuid-universally-unique-identifier/" data-a2a-title="PostgreSQL: Optimized way to populate new Column (UUID) in a Large Table"></a></p><p>The default nature of PostgreSQL is based on MVCC architecture which managed by different type of ROW versions.<br />
You can read more about MVCC,</p>
<blockquote class="wp-embedded-content" data-secret="bpjesSACk4"><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=bpjesSACk4" data-secret="bpjesSACk4" 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>Why I have started this article with MVCC because whenever we update data into the table, it creates a new record and marked the old record as an old version or dead tuple.</p></blockquote>
<p>You can visit UUID related article here,</p>
<blockquote class="wp-embedded-content" data-secret="HcGrULmlEJ"><p><a href="https://www.dbrnd.com/2016/03/database-theory-the-truth-about-universally-unique-identifier-uuid/">Database Theory: The truth about Universally Unique Identifier &#8211; UUID</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/database-theory-the-truth-about-universally-unique-identifier-uuid/embed/#?secret=HcGrULmlEJ" data-secret="HcGrULmlEJ" width="600" height="338" title="&#8220;Database Theory: The truth about Universally Unique Identifier &#8211; UUID&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="cFzokz062d"><p><a href="https://www.dbrnd.com/2016/03/postgresql-working-with-universally-unique-identifier-uuid-data-type/">PostgreSQL: Working with Universally Unique Identifier &#8211; UUID Data type</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/postgresql-working-with-universally-unique-identifier-uuid-data-type/embed/#?secret=cFzokz062d" data-secret="cFzokz062d" width="600" height="338" title="&#8220;PostgreSQL: Working with Universally Unique Identifier &#8211; UUID Data type&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>My problem:</strong></p>
<blockquote><p>One of our table size is more than 30gb and I got one requirement to add one new column with default UUID data. This table is already loaded by bulk insertion and exclusive lock never work in this situation. </p></blockquote>
<blockquote><p>While adding a column with default value requires PostgreSQL to make new versions of all rows, rewritten the entire table &#8211; indexes and store them on the disk and during that time Table will be locked.</p></blockquote>
<p><strong>The Solution should be like:</strong></p>
<blockquote><p>This task is required to perform on Production report server so it is very much important to take care about everything like: no exclusive lock, within given time frame limit, data should not be fragmented.<br />
I have tried different approaches which are, I am going to share in this article.</p></blockquote>
<p><strong>Option 1: </strong></p>
<blockquote><p>Add new column with NULL value, do not assign any default value in ALTER statement. </p></blockquote>
<blockquote><p>After adding a new column, we should run different small batches to update the newly created column.</p></blockquote>
<blockquote><p>Find out data fragmentation, dead tuples and try to optimize and remove using VACUUM &#8211; ANALYZE.</p></blockquote>
<p><strong>Option 2:</strong></p>
<blockquote><p>CREATE one new blank table with require all old and new columns.<br />
Create different small batches and move data from Old table to the newly created table. </p></blockquote>
<blockquote><p>While transferring the data, populate default value of the new column. (In my case, I have generated UUID on the fly)<br />
ADD all require constraint and indexes on the newly created table.<br />
Stop all the running data insertion queues for a while, drop the old table and rename a  new table to require an original table name. </p></blockquote>
<p>Yet, I am not 100% sure about these approaches, but I have done my task without any locking issue and completed within given time frame. </p>
<p><strong>If you have any other optimized way, Please share your ideas.</strong></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
