Environment:
Oracle 8i (8.1.7)
Scenario:
Three columns are retrieved -
CURSOR cur_name IS
SELECT c1, c2, c3
FROM tab_A;
Let's say the original retrieved values are equal to:
c1=old_value1, c2=old_value2, c3=old_value3
Some processing take place and we find new values of c1, c2, and c3.
Final step is to update columns c1, c2, c3 in tab_A with the new values.
Question:
What is the fastest way of doing this? (A), (B), or (C)?
Option A:
CURSOR cur_name IS
SELECT c1, c2, c3
FROM tab_A;
FOR rec IN cur_name LOOP
... processing of c1,c2,c3
... getting new values of c1,c2,c3
UPDATE tab_A
SET c1 = new_value1, c2 = new_value2, c3 = new_value3
WHERE c1 = rec.old_value1, c2 = rec.old_value2, c3 = rec.old_value3;
END LOOP;
Note: Created nonunique index on (c1,c2,c3).
Option B:
CURSOR cur_name IS
SELECT c1, c2, c3, ROWID
FROM tab_A;
FOR rec IN cur_name LOOP
... processing of c1,c2,c3
... getting new values of c1,c2,c3
UPDATE tab_A
SET c1 = new_value1, c2 = new_value2, c3 = new_value3
WHERE ROWID = rec.ROWID
END LOOP;
Note: The best elapsed time I got was 224 seconds for updating 1,021,000 records.
Option C:
any other idea?
Thank you.
<ruse7013>
Oracle 8i (8.1.7)
Scenario:
Three columns are retrieved -
CURSOR cur_name IS
SELECT c1, c2, c3
FROM tab_A;
Let's say the original retrieved values are equal to:
c1=old_value1, c2=old_value2, c3=old_value3
Some processing take place and we find new values of c1, c2, and c3.
Final step is to update columns c1, c2, c3 in tab_A with the new values.
Question:
What is the fastest way of doing this? (A), (B), or (C)?
Option A:
CURSOR cur_name IS
SELECT c1, c2, c3
FROM tab_A;
FOR rec IN cur_name LOOP
... processing of c1,c2,c3
... getting new values of c1,c2,c3
UPDATE tab_A
SET c1 = new_value1, c2 = new_value2, c3 = new_value3
WHERE c1 = rec.old_value1, c2 = rec.old_value2, c3 = rec.old_value3;
END LOOP;
Note: Created nonunique index on (c1,c2,c3).
Option B:
CURSOR cur_name IS
SELECT c1, c2, c3, ROWID
FROM tab_A;
FOR rec IN cur_name LOOP
... processing of c1,c2,c3
... getting new values of c1,c2,c3
UPDATE tab_A
SET c1 = new_value1, c2 = new_value2, c3 = new_value3
WHERE ROWID = rec.ROWID
END LOOP;
Note: The best elapsed time I got was 224 seconds for updating 1,021,000 records.
Option C:
any other idea?
Thank you.
<ruse7013>