delete procedure taking time [message #486980] |
Tue, 21 December 2010 20:45  |
|
Hi All,
Below pl/sql procedure is taking more than 1 hour. Count in history table is 55156678 and table is having two indexes. Could you please let me know what things i need check.
DECLARE
v_pub_date_cnt NUMBER;
v_pub_date_min erp_booking_hist.publish_date%TYPE;
BEGIN
BEGIN
SELECT COUNT (DISTINCT publish_date), MIN (publish_date)
INTO v_pub_date_cnt, v_pub_date_min
FROM erp_booking_hist;
EXCEPTION
WHEN OTHERS
THEN
v_pub_date_cnt := 0;
END;
IF v_pub_date_cnt > 5
THEN
DELETE FROM erp_booking_hist
WHERE publish_date = v_pub_date_min;
COMMIT;
END IF;
END;
Thanks,
sagar
|
|
|
|
|
|
|
|
|
Re: delete procedure taking time [message #486998 is a reply to message #486986] |
Wed, 22 December 2010 00:01  |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Looks like you could be trying to delete 10% or more of the table (5M rows). Deleting that many rows is going to take a heap of time, because every block impacted must be rewritten, which in turn generates the same amount of IO on the UNDO segments and the Archive logs.
It would almost certainly be faster to rebuild the table from scratch. Or perhaps you could partition the table on the PUBLISH_DATE and TRUNCATE PARTITION instead of deleting.
Ross Leishman
|
|
|