Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Statspack archiving
The original question on this thread was for an automated "purge" for
STATSPACK. I wrote this stored procedure based on the v8.1.7 version of the
standard "sppurge.sql" script. I'd use that script, except I don't like the
way it is called (i.e. range of SNAP_IDs). This stored procedure figures
out the range of SNAP_IDs based on the parameter indicating the number of
days of data to retain...
Hope this helps -- as always, no warranties!
spool sppurpkg
connect perfstat
show user
show release
set termout off
create or replace package SPPURPKG
is
--
procedure PURGE(in_days_older_than IN INTEGER);
--
end SPPURPKG;
/
set termout on
show errors
set termout off
create or replace package body SPPURPKG
is
--
procedure PURGE(in_days_older_than IN INTEGER)
is
--
cursor get_snaps(in_days IN INTEGER)
is
select s.rowid,
s.snap_id, s.dbid, s.instance_number
from stats$snapshot s where s.dbid = i.dbid and s.instance_number = i.instance_number and s.startup_time = i.startup_time);
from stats$snapshot s where s.dbid = p.dbid and s.instance_number = p.instance_number);
variable jobno number;
begin
dbms_job.submit(:jobno, 'sppurpkg.purge(14);', sysdate+(1/1440),
'SYSDATE+1', TRUE);
commit;
end;
/
set pages 100
select * from user_jobs where job = :jobno;
spool off
----------------------- end included SQL*Plus script ------------------------------
> > Hey Jared, > > Did you do anything with statspack or the wait interface in your > > toolset/book? Gotta get a copy for inspiration. > > No, no wait interface stuff, at least, I don't remember any. > > You're correct about writing code for others to see. It's one > thing to write code for internal use, but just try packaging > it and writing coherent documentation. The amount of effort > shoots *wayyyy* up. > > I have ideas for new iterations of the toolkit that is > included in the book, but I'll wait and see what others > like and dislike, and what they think is missing. > > Probably a lot. Can't really pack too much into a couple > hundred pages. > > Jared > > -- > Please see the official ORACLE-L FAQ: http://www.orafaq.com > -- > Author: > INET: Jared.Still_at_radisys.com > > Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 > San Diego, California -- Public Internet access / Mailing Lists > -------------------------------------------------------------------- > To REMOVE yourself from this mailing list, send an E-Mail message > to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in > the message BODY, include a line containing: UNSUB ORACLE-L > (or the name of mailing list you want to be removed from). You may > also send the HELP command for other information (like subscribing).
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Tim Gorman INET: Tim_at_SageLogix.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Sat Aug 10 2002 - 14:53:18 CDT