fast
A reader, January 04, 2016 - 4:33 pm UTC
Rowid is the fastest way to update a row or delete a row from a table.
To Chris
Rajeshwaran Jeyabal, January 07, 2016 - 1:22 pm UTC
That said, your code selects and updates the same table. So it may be quicker to do the update in a single statement. From what I understand of the above, it looks like you can do:
update temp_table
set nrow_id = rowid;
Though why you want to set a column to the rowid is beyond me! looking into the initial code it is
....
FORALL I IN ROWID_TAB.FIRST .. ROWID_TAB.LAST
UPDATE /*+ PARALLEL(TEMP_TABLE 12) */ TEMP_TABLE NOLOGGING
SET NROW_ID = ROW_ID
WHERE ROWID = ROWID_TAB(I) AND ROW_ID IS NULL;
COMMIT;
....
which says
1) for each ROWID available in the collection ROWID_TAB(I)
2) check if the corresponding row in table has ROW_ID as NULL
3) if yes then update table NROW_ID WITH ROW_ID (not ROWID)
so the update become this way
update temp_table
set nrow_id = row_id
where row_id is NULL;
or
update temp_table
set nrow_id = NULL
where row_id is NULL;
January 07, 2016 - 4:32 pm UTC
Yes, to match the original code you need to at the where clause. I'm still not sure why the poster wants to do this though.