<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: avoiding &#8220;empty&#8221; updates</title>
	<atom:link href="http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 21:40:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Lecy</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-29147</link>
		<dc:creator>Lecy</dc:creator>
		<pubDate>Thu, 21 Jan 2010 16:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-29147</guid>
		<description>Looks like I was a bit late on this one but it&#039;s really a good post.  I&#039;m thinking about a reply on my site . . .  Art Of War&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Looks like I was a bit late on this one but it&#8217;s really a good post.  I&#8217;m thinking about a reply on my site . . .  Art Of War</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: &#60;/depesz&#62; &#187; Blog Archive &#187; avoiding &#8220;empty&#8221; updates - part2</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-24768</link>
		<dc:creator>&#60;/depesz&#62; &#187; Blog Archive &#187; avoiding &#8220;empty&#8221; updates - part2</dc:creator>
		<pubDate>Mon, 21 Jan 2008 20:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-24768</guid>
		<description>[...] time ago i wrote about potential (or not potential, depending on your situation) problem with updates which do not [...]</description>
		<content:encoded><![CDATA[<p>[...] time ago i wrote about potential (or not potential, depending on your situation) problem with updates which do not [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-24626</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Wed, 02 Jan 2008 14:45:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-24626</guid>
		<description>@Andrew Dunstan:
i will test it soon. i just have to finish some other tasks.</description>
		<content:encoded><![CDATA[<p>@Andrew Dunstan:<br />
i will test it soon. i just have to finish some other tasks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Dunstan</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-24625</link>
		<dc:creator>Andrew Dunstan</dc:creator>
		<pubDate>Wed, 02 Jan 2008 14:39:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-24625</guid>
		<description>The penalty you are seeing above is almost certainly due to your using plpgsql for the trigger, and to using the row constructor to do field by field comparison. Try my C version, which compares using memcmp on the whole record in one hit, and you will see far better results.</description>
		<content:encoded><![CDATA[<p>The penalty you are seeing above is almost certainly due to your using plpgsql for the trigger, and to using the row constructor to do field by field comparison. Try my C version, which compares using memcmp on the whole record in one hit, and you will see far better results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-20897</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Sun, 09 Sep 2007 12:06:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-20897</guid>
		<description>@David Fetter:
true. in fact - i&#039;m not fan of rules, so i dont know them well, but in this situation rule seems to be perfect as it works before any kind of triggers, and checks.</description>
		<content:encoded><![CDATA[<p>@David Fetter:<br />
true. in fact &#8211; i&#8217;m not fan of rules, so i dont know them well, but in this situation rule seems to be perfect as it works before any kind of triggers, and checks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-20896</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Sun, 09 Sep 2007 12:04:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-20896</guid>
		<description>@Radim Kolar:
the fact that mysql does something doesn&#039;t really prove anything. they also &quot;do&quot; commands that can work partially :)

and on the more serious side - i can see some uses to make empty updates. side-effects of update triggers are the first to think about.
plus - comparing (as Jeff mentioned) might be costly - remember that a single column might be up to 1gb of data! i definitely don&#039;t want database to waste time with comparing this kind of data. and if i want - a trigger (or rule, as David showed) is really simple.</description>
		<content:encoded><![CDATA[<p>@Radim Kolar:<br />
the fact that mysql does something doesn&#8217;t really prove anything. they also &#8220;do&#8221; commands that can work partially <img src='http://www.depesz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>and on the more serious side &#8211; i can see some uses to make empty updates. side-effects of update triggers are the first to think about.<br />
plus &#8211; comparing (as Jeff mentioned) might be costly &#8211; remember that a single column might be up to 1gb of data! i definitely don&#8217;t want database to waste time with comparing this kind of data. and if i want &#8211; a trigger (or rule, as David showed) is really simple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-20865</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Sun, 09 Sep 2007 02:47:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-20865</guid>
		<description>I agree that it could be done in the database. But in theory, comparing two records for every update could be costly, since PostgreSQL supports user-defined types, and out-of-line storage. 

If you update based on a simple integer key, but another value in the same record is large and held in a separate physical location, the comparison could require reading additional data. 

This could probably be optimized, but at least there are triggers if you really need them. I suspect that you could make the overhead of such a trigger negligible.</description>
		<content:encoded><![CDATA[<p>I agree that it could be done in the database. But in theory, comparing two records for every update could be costly, since PostgreSQL supports user-defined types, and out-of-line storage. </p>
<p>If you update based on a simple integer key, but another value in the same record is large and held in a separate physical location, the comparison could require reading additional data. </p>
<p>This could probably be optimized, but at least there are triggers if you really need them. I suspect that you could make the overhead of such a trigger negligible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Fetter</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-20863</link>
		<dc:creator>David Fetter</dc:creator>
		<pubDate>Sun, 09 Sep 2007 02:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-20863</guid>
		<description>Another way to do this, using RULEs :)

CREATE RULE no_unchanging_updates AS
    ON UPDATE
    TO test
    WHERE ROW(OLD.*) IS NOT DISTINCT FROM ROW(NEW.*)
    DO INSTEAD NOTHING;</description>
		<content:encoded><![CDATA[<p>Another way to do this, using RULEs <img src='http://www.depesz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>CREATE RULE no_unchanging_updates AS<br />
    ON UPDATE<br />
    TO test<br />
    WHERE ROW(OLD.*) IS NOT DISTINCT FROM ROW(NEW.*)<br />
    DO INSTEAD NOTHING;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radim Kolar</title>
		<link>http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/comment-page-1/#comment-20845</link>
		<dc:creator>Radim Kolar</dc:creator>
		<pubDate>Sat, 08 Sep 2007 23:14:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/09/08/avoiding-empty-updates/#comment-20845</guid>
		<description>No, avoiding empty updates is work for DB server. MYSQL is doing that.</description>
		<content:encoded><![CDATA[<p>No, avoiding empty updates is work for DB server. MYSQL is doing that.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
