performance of updates

From: Ed Prochak <edprochak_at_gmail.com>
Date: Thu, 18 Dec 2008 06:53:36 -0800 (PST)
Message-ID: <d69c5cc8-dd5c-4a5a-bbe4-ca558472a2c7@e18g2000vbe.googlegroups.com>


I am in the midst of some performance improvements. I have never thought about this aspect before but has anyone tested the difference in performance between

UPDATE mytable SET
 status = new_status
WHERE mykey = thiskey;

and

UPDATE mytable SET
 status = new_status
WHERE mykey = thiskey
  AND status <> new_status;

???

I haven't run my own test yet. The actual UPDATE is in a trigger but I don't think that matters. The argument a coworker is making is that we should update only if it makes a difference (ie if the value changed). Since this is an update to one row, I'm not sure if the overhead of checking additional columns is worth the minimal savings of avoiding writing the data.

The difference seems to me like it would be minimal. Anyone have evidence either way?

  Ed Received on Thu Dec 18 2008 - 08:53:36 CST

Original text of this message