Forall bulk delete is too slow to work,seek advice.
citicbjOct 28 2009 — edited Nov 18 2009I used PL/SQL stored procedure to do some ETL work. It is pick up refeshed records from staging table, then check to see whether the same record exists in target table, then do a Forall bulk deletion first, then do a Forall insert all refreshed records into target atble. the insert part is working fine. Only is the deleteion part, it is too slow to get job done. My code list below. Please advise where is the problem? Thansk.
Declare
TYPE t_distid IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
v_distid t_distid;
CURSOR dist_delete IS
select distinct distid FROM DIST_STG where data_type = 'H';
OPEN dist_delete;
LOOP
FETCH dist_delete BULK COLLECT INTO v_distid;
FORALL i IN v_distid.FIRST..v_distid.LAST
DELETE DIST_TARGET WHERE distid = v_distid(i);
END LOOP;
COMMIT;
end;
/