<?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>The eflow blog &#187; sql</title>
	<atom:link href="http://blog.eflow.org/archives/tag/sql/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eflow.org</link>
	<description>Insert some amazingly witty tagline here</description>
	<lastBuildDate>Fri, 09 Dec 2011 18:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Updating UUID Column in the Large Obs Table</title>
		<link>http://blog.eflow.org/archives/276</link>
		<comments>http://blog.eflow.org/archives/276#comments</comments>
		<pubDate>Thu, 07 Jan 2010 15:43:04 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[openmrs]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[uuid]]></category>

		<guid isPermaLink="false">http://blog.eflow.org/?p=276</guid>
		<description><![CDATA[We have well over 50 million rows in our obs table. Using the simple &#8220;update obs set uuid = uuid() where uuid is null&#8221; would bomb out with a &#8220;The total number of locks exceeds the lock table size&#8221; error. I ran this for a few hours to get through all rows. (Note that it [...]]]></description>
			<content:encoded><![CDATA[<p>We have well over 50 million rows in our obs table.  Using the simple &#8220;update obs set uuid = uuid() where uuid is null&#8221; would bomb out with a &#8220;The total number of locks exceeds the lock table size&#8221; error.</p>
<p>I ran this for a few hours to get through all rows.  (Note that it overwrites any uuids that are currently there)</p>
<p>Copy this into a sql script and run it with &#8220;source&#8221; in mysql at command line.</p>
<blockquote><p>
drop procedure update_uuids;<br />
delimiter //<br />
create procedure update_uuids() begin<br />
set @max = (select max(obs_id) from obs);<br />
set @x = 1;<br />
repeat<br />
set @y = @x + 100000;<br />
update obs set uuid = uuid() where obs_id >=@x and obs_id <@y;<br />
set @x = @y;<br />
until @x > @max<br />
end repeat;<br />
end<br />
//<br />
delimiter ;<br />
call update_uuids();
</p></blockquote>
 <img src="http://blog.eflow.org/wp-content/plugins/feed-statistics.php?view=1&post_id=276" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.eflow.org/archives/276/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

