|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Data Purging [message #576753 is a reply to message #576635] |
Thu, 07 February 2013 14:01   |
Bill B
Messages: 985 Registered: December 2004
|
Senior Member |
|
|
Using a loop is the slowest possible way to delete the rows. The fastest is
delete from SITE.EMAIL_AUDIT where status='SENT' and uuid is not null and date_requested < sysdate-3;
commit;
|
|
|
|
| Re: Data Purging [message #576758 is a reply to message #576753] |
Thu, 07 February 2013 14:31  |
 |
alan.kendall@nfl.com
Messages: 160 Registered: June 2012 Location: Culver City, California
|
Senior Member |
|
|
It is the slowest but it causes the least locks on tables that are being updated frequently. I can run the following script in another session, and if locking occurs, I see it and I kill my purging process. I can run the deletes in the day and permanently schedule them in the night with no worries. I used to delete and commit 1000 rows at a time but had locking so I reduced deletes to 100 rows, had locking so now I delete 10 rows at a time and the locking went away.
ENWEBP1P > @active
SID SERIAL# MACHINE LOGIN DB SEC_WAIT USERNAME EVENT
---- ------- ------------ --------------- ------ -------- --------- ------------------
1954 4761 US\KENDALLA- 07-FEB-13 12:11 NWEBP2 0 ENWEBP2P gc current request
1832 14525 prodapp04 06-FEB-13 21:39 NWEBP4 0 SITE_USER SQL*Net message to
1010 517 US\KENDALLA- 07-FEB-13 12:09 NWEBP3 0 ENWEBP3P gc current request
The full sql follows:
set lines 200
set pages 50
set trunc off
set wrap off
column username print
column username format a11
column program format a60
column machine format a18
column sid format 999999
col sec_wait format 9999999
column serial# format 999999
column login format a15
col db for a10
col sid print
col serial# print
SELECT sid,
serial#,
machine,
To_char(s.logon_time, 'DD-MON-RR HH24:MI') login,
i.instance_name db,
s.seconds_in_wait sec_wait,
s.username,
s.event,
s.status,
s.program,
s.machine,
s.MODULE,
s.terminal
FROM gv$session s,
gv$instance i
WHERE i.inst_id = s.inst_id
AND s.status = 'ACTIVE'
AND s.username IS NOT NULL
AND s.wait_class <> 'Idle'
--and seconds_in_wait>0
ORDER BY seconds_in_wait
/
I find the advantage of being able to do purges on critical tables during normal working hours a big benefit.
|
|
|
|