Home > Oracle > Generating statspack quickly for Oracle

Generating statspack quickly for Oracle

This process has been tested from 9i to 11gR2.  Oracle still supports statspack, but preference is to use AWR — an  additional license is required to use, however.

Note the 2 files named:
– spreport_auto.sql
– DayReports.sql

Running spreport_auto.sql will generate a new DayReports.sql.

For example, if today is the 10th day of the month and you want statspack from 2 days ago (8th), then
you will modify this line in spreport_auto.sql:
## from
where trunc(snap_time) = trunc(sysdate -1)

## to
where trunc(snap_time) = trunc(sysdate -2)

Save the file.

Run:
sqlplus perfstat/perfstat @spreport_auto.sql
sqlplus perfstat/perfstat @DayReports.sql

Note, the statspack reports generated as sp_MMDDHHHH.txt in the CWD.

Contents of spreport_auto.sql:

spool DayReports.sql

set heading off pages 9999

select ‘define begin_snap=’||snap_id||’;’||chr(10)||
‘define end_snap=’||to_number(snap_id + 1)||’;’||chr(10)||
‘define report_name=sp_’||to_char(snap_time,’mmddhh24mi’)||’.txt’||chr(10)||
‘@?/rdbms/admin/spreport;’||chr(10)
from stats$snapshot
where trunc(snap_time) = trunc(sysdate -1)
order by snap_time asc;

spool off

Categories: Oracle
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: