<?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>Tech Blog &#187; update delayed</title>
	<atom:link href="http://informationideas.com/news/tag/update-delayed/feed/" rel="self" type="application/rss+xml" />
	<link>http://informationideas.com/news</link>
	<description>Using technology to help your business</description>
	<lastBuildDate>Thu, 05 Aug 2010 22:53:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Update Delayed on Mysql and PHP</title>
		<link>http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/</link>
		<comments>http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 23:10:12 +0000</pubDate>
		<dc:creator>frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[update delayed]]></category>

		<guid isPermaLink="false">http://informationideas.com/news/?p=68</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice if we could use UPDATE DELAYED in mysql just like we do use INSERT DELAYED? Unfortunately, the work around mysql created for this is to insert a record into the events table in order to separate UPDATE statement into another thread. There is a large overhead to inserting to then execute [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice if we could use UPDATE DELAYED in mysql just like we do use INSERT DELAYED?  Unfortunately, the work around mysql created for this is to insert a record into the events table in order to separate UPDATE statement into another thread.  There is a large overhead to inserting to then execute an update.</p>
<p>If you are using PHP with mysql, there is another work around.Â  PHP has a function called, register_shutdown_function, which will execute a function during the shutdown of processing a script file.  So if we add an UPDATE LOW_PRIORITY sql statement wrapped in a function that is passed to register_shutdown_function, we can allow the user to receive the page without delay while the UPDATE statement waits until all locks on the table has been release before proceeding.<br />
<code><br />
function update_delayed()<br />
{<br />
    $sql = "UPDATE LOW_PRIORITY table_name SET col1 = 'something'";<br />
    mysql_query($sql, $conn);<br />
}</p>
<p>register_shutdown_function('update_delayed');<br />
</code></p>
<p>I wonder if there are even better ways to handle this problem.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/&amp;title=Update+Delayed+on+Mysql+and+PHP" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/&amp;title=Update+Delayed+on+Mysql+and+PHP" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/&amp;t=Update+Delayed+on+Mysql+and+PHP" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/&amp;title=Update+Delayed+on+Mysql+and+PHP&amp;summary=Wouldn%27t%20it%20be%20nice%20if%20we%20could%20use%20UPDATE%20DELAYED%20in%20mysql%20just%20like%20we%20do%20use%20INSERT%20DELAYED%3F%20%20Unfortunately%2C%20the%20work%20around%20mysql%20created%20for%20this%20is%20to%20insert%20a%20record%20into%20the%20events%20table%20in%20order%20to%20separate%20UPDATE%20statement%20into%20another%20thread.%20%20There%20is%20a%20large%20overhead%20to%20inserting%20to%20the&amp;source=Tech Blog" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Update+Delayed+on+Mysql+and+PHP+-+http://b2l.me/acsyu2&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://informationideas.com/news/2008/12/11/update-delayed-on-mysql-and-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
