Connecting Tech Pros Worldwide Forums | Help | Site Map

Updating an indexed column with the same existing value

Mark A
Guest
 
Posts: n/a
#1: Nov 21 '08
Suppose a table like this:

CREATE TABLE TABLE_A
(COL_1 INT NOT NULL PRIMARY KEY,
COL_2 CHAR(1) NOT NULL);

and a SQL statement like this:

UPDATE TABLE_A SET COL_1 = ? AND COL_2 =? WHERE COL_1 = ?;

The SQL is prepared using Type 4 Java driver and executed.

If the value of COL_1 is always the same as the existing value, but COL_2 is
always different than the existing value, does DB2 actually update/log the
update of COL_1 and the update the index on column COL_1 even though the
value has not changed?

In other words, the SQL should look like this:

UPDATE TABLE_A SET COL_2 =? WHERE COL_1 = ?;

This is a very high volume SQL statement in an application and I am trying
to assess how much extra work is being done by DB2 that should not be done
if the SQL was coded properly (because the COL_1 value never actually
changes).





Closed Thread