Re: UPDATE sql question

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: UPDATE sql question
Date: 2003-08-01 15:54:25
Message-ID: 1059753264.7508.612.camel@haggis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2003-08-01 at 10:16, Tom Lane wrote:
> Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> writes:
> > On Mon, 2003-07-28 at 03:24, Andrei Verovski wrote:
> >> What exactly will happen if UPDATE sql statement instructs to update
> >> some columns with the same values as already in the database? Will
> >> Postgres update only different values or it will simply modify all
> >> columns listed in UPDATE sql?
>
> > Looks like it does what you tell it to do...
>
> I think he was asking an implementation question, viz: does it skip the
> physical update if no values in a row actually change? The answer is
> no. I'd think that in most cases, the extra time spent checking to see
> whether the updated columns didn't change would be a net loss.

Would it always be a net loss, though?

If *none* of the fields were updated, then you could burn some CPU
(doing comparisons) to save a disk write.

CPUs are so fast, nowadays. How many microseconds *would* be spent?

Of course, one could always say, "Hey, application! Don't update
unchanged values!!!!".

--
+-----------------------------------------------------------------+
| Ron Johnson, Jr. Home: ron(dot)l(dot)johnson(at)cox(dot)net |
| Jefferson, LA USA |
| |
| "I'm not a vegetarian because I love animals, I'm a vegetarian |
| because I hate vegetables!" |
| unknown |
+-----------------------------------------------------------------+

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-08-01 16:15:45 Re: UPDATE sql question
Previous Message Christopher Browne 2003-08-01 15:48:01 Re: Views With Unions