Subject | Updating performace using IN or separated UPDATES |
---|---|
Author | Filipe Bortolini |
Post date | 2004-04-02T16:47:12Z |
Hi,
I was updating a table with a large number of records and I found something
interesting
if i do the update like this:
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2 in (1,2,3)
I get a response time of 1 minute and 40 seconds.
If I do three separated updates, like:
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2= 1;
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2 = 2;
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2 = 3;
it executes in 17 seconds
What is the reason to such difference if the number of reads in the table
are the same?
(PS: There can be only one line in TABLE for FIELD1 to a value of FIELD2
(example (FIELD1= X and FIELD2 = 1) or (FIELD1= X and FIELD2 = 2) or
(FIELD1= X and FIELD2 = 3)).
I was updating a table with a large number of records and I found something
interesting
if i do the update like this:
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2 in (1,2,3)
I get a response time of 1 minute and 40 seconds.
If I do three separated updates, like:
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2= 1;
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2 = 2;
update TABLE set
<...etc...>
where FIELD1 = X and FIELD2 = 3;
it executes in 17 seconds
What is the reason to such difference if the number of reads in the table
are the same?
(PS: There can be only one line in TABLE for FIELD1 to a value of FIELD2
(example (FIELD1= X and FIELD2 = 1) or (FIELD1= X and FIELD2 = 2) or
(FIELD1= X and FIELD2 = 3)).