update performance
Posted in 2001
Topics: Performance & Tuning, Server Administration
I have to make a query that will update a field of type smallint (a bool really), and I have a big amount of values (one per row in the table) which are 0 or 1. Now, I could make an update of all the column, but maybe only 5% of the columns have been changed. What should I use to tell informix only to update the colunms which have a different value? Thanks -- System Administration: It's a dirty job, but someone told I had to do it. ----------------------------------------------------------------- Mart'n Marqu's email: martin@math.unl.edu.ar Santa Fe - Argentina http://math.unl.edu.ar/~martin/ Administrador de sistemas en math.unl.edu.ar -----------------------------------------------------------------
In the year of Our Lord Mon, 12 Feb 2001 18:26:49 -0300, "Martin A. Marques" <martin@math.unl.edu.ar> spake, saying: >I have to make a query that will update a field of type smallint (a bool >really), and I have a big amount of values (one per row in the table) which >are 0 or 1. >Now, I could make an update of all the column, but maybe only 5% of the >columns have been changed. >What should I use to tell informix only to update the colunms which have a >different value? I certainly speak for each of my multiple personalities when I say I don't understand the question. How do you know a row has changed?
"Martin A. Marques" wrote:
>
> I have to make a query that will update a field of type smallint (a bool
> really), and I have a big amount of values (one per row in the table) which
> are 0 or 1.
> Now, I could make an update of all the column, but maybe only 5% of the
> columns have been changed.
> What should I use to tell informix only to update the colunms which have a
> different value?
I don't fully understand the question, but I'll take a stab at it
anyway.
UPDATE YourTable SET BoolColumn = 1
WHERE BoolColumn = 0 AND ...whatever other conditions you need...
UPDATE YourTable SET BoolColumn = 0
WHERE BoolColumn = 1 AND ...whatever other (different) conditions...
If the processing has to scan the table anyway, then updating the
columns even when not needing to be changed may even be quicker than
double scanning the table; that depends on the other conditions, any
indexes, and so on.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"