Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Poor performance of update

tech_usrMay 31 2006 — edited May 31 2006
Hi,

I'm having a performance issue with the updates that run on a huge partitioned table. Here are the details -

Table_A has 80 million records, it has columns - pk_col (this is primary key), col1 & col2.
Table_B is a partitioned table that has a total of 100 million records (each partition has about 9 million records). It has columns pk_b_col (this is the primary key), new_col and some other columns.
Here is a snippet of my pl/sql procedure that does the update on Table_B. I'm using primary key to do update and I was hoping the update to take atmost 1min for 60000 records (which is my fetch limit). But unfortunately, its taking about 20 min to update 60000 records. Can someone let me know if there's anything I can try to improve the performance of these queries?

Also, how does the fetch cursor work? does oracle run the fetch cursor query once for each fetch? or is the result of cursor query stored in memory and fetch just gets a subset of that data each time?

-----------------------------------------------------------------------------------------------------------------------------

CURSOR get_data_cur IS
SELECT pk_col, min(col1-col2)
FROM Table_A
GROUP BY pk_col;
-- This query would return about 40 million records

FETCH get_data_cur BULK COLLECT INTO v_col1, v_col2 LIMIT 60000;

FORALL index IN v_col1.FIRST..v_co1.LAST
UPDATE Table_B
SET new_col = v_col2
WHERE pk_b_col = v_col1
AND (new_col IS NULL OR new_col > v_col2);

-----------------------------------------------------------------------------------------------------------------------------

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 28 2006
Added on May 31 2006
5 comments
288 views