I have below block, and it is taking 8 to 9 hours for 450k data to complete. How to improve performance in that case? tab_a is having 10M data.
Declare
cursor cur_dup is
Select col_a,col_b,count(1) from tab_a group by col_a,col_b having count(1) > 1;
Begin
for cur_dup_rec in cur_dup loop
update tab_a
set qty = 0
where col_a = cur_dup_rec.col_a and col_b = cur_dup_rec.col_b
and trunc(u_created_date) <> (Select max(trunc(u_created_date)) from tab_a
where col_a = cur_dup_rec.col_a and col_b = cur_dup_rec.col_b);
update tab_a
set (u_modified_date) = trunc(sysdate)
where col_a = cur_dup_rec.col_a and col_b = cur_dup_rec.col_b;
for cur_dup2_rec in (Select distinct item,customer,location,requested_date
from tab_a
where col_a = cur_dup_rec.col_a and col_b = cur_dup_rec.col_b) loop
update tab_a
set (u_modified_date) = trunc(sysdate)
where item = cur_dup2_rec.item and customer = cur_dup2_rec.customer and location = cur_dup2_rec.location
and to_char(requested_date,'DD-MON-YYYY') = cur_dup2_rec.requested_date;
end loop;
end loop;
End;
3