In relation to my last post, I have a question for the SQL-gurus.
I need to update 70k records, and mark all those updated in a special
column for further processing by another system.
So, if the record was
Key1, foo, foo, ""
it needs to become
Key1, fap, fap, "U"
iff and only iff the datavalues are actually different (as above, foo
becomes fap),
otherwise it must become
Key1, foo,foo, ""
Is it quicker to :
1) get the row of the destination table, inspect all values
programatically , and determine IF an update query is needed
OR
2) just do a update on all rows, but adding
and (field1 <> value1 or field2<>value2) to the update query
that is
update myTable
set
field1 = "foo"
markField="u"
where key="mykey" and (field1 <> foo)
The first one will not generate new update queries if the record has
not changed, on account of doing a select, whereas the second version
always runs an update, but some of them will not affect any lines.
Will I need a full index on the second version?
Thanks in advance,
Asger Henriksen
I need to update 70k records, and mark all those updated in a special
column for further processing by another system.
So, if the record was
Key1, foo, foo, ""
it needs to become
Key1, fap, fap, "U"
iff and only iff the datavalues are actually different (as above, foo
becomes fap),
otherwise it must become
Key1, foo,foo, ""
Is it quicker to :
1) get the row of the destination table, inspect all values
programatically , and determine IF an update query is needed
OR
2) just do a update on all rows, but adding
and (field1 <> value1 or field2<>value2) to the update query
that is
update myTable
set
field1 = "foo"
markField="u"
where key="mykey" and (field1 <> foo)
The first one will not generate new update queries if the record has
not changed, on account of doing a select, whereas the second version
always runs an update, but some of them will not affect any lines.
Will I need a full index on the second version?
Thanks in advance,
Asger Henriksen
Comment