Re: Rewritten rows on unchanged values

From: Bertrand Janin <b(at)janin(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Rewritten rows on unchanged values
Date: 2013-03-22 14:50:39
Message-ID: 20130322145039.GA9039@tamentis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hannes Erven wrote :
> Hi folks,
>
>
> On 2013-03-22 13:32, Bertrand Janin wrote:
> > UPDATE demo
> > SET value = value
> > WHERE id = 1;
>
>
> On 2013-03-22 14:55, Tom Lane wrote:
> >
> >It's not *necessary* to do so. However, avoiding it would require
> >sitting there and comparing the old and new tuples,
>
>
> But in this case, no tuples would need to be compared: just by
> looking at the query is becomes clear that it is a no-op.
> Isn't this something the planner is or could be aware of?
>
> Betrand, out of curiosity: is this a synthentic test case or do you
> really have an application that generates queries like this?

I used the value=value to emphasize the example, in my use case it would be
value='whatever is already there'.

Tom is right, this would be an optimization for a corner case, I noticed this
when running a generated script for a batch update that wasn't given a ton of
attention. The BEFORE UPDATE trigger will work great.

-b

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2013-03-22 14:53:44 Referencing parts captured by round brackets in a regex in 8.4.13
Previous Message Alexander Farber 2013-03-22 14:23:42 Re: Re: Matching uppercased russian words (\x0410-\x042F) in UTF8 database 8.4.13