Stats Pack
Stats Pack
Stats Pack
Description
On earlier version of Oracle, previous to Oracle 8i, one very useful way to analyze
performance of an instance was to use utlbestat and utlestat. From Oracle 8i and upper
versions, Oracle enables another way to generate reports with a profile of the database
during a specific period of time and it is called StatsPack. This document is specially
described for Oracle 8.1.6 version and upper.
Statspack fundamentally differs from the well known UTLBSTAT/UTLESTAT tuning
scripts by collecting more information, and also by storing the performance statistics data
permanently in Oracle tables, which can later be used for reporting and analysis. The
data collected can be analyzed using the report provided, which includes an "instance
health and load" summary page, high resource SQL statements, as well as the traditional
wait events and initialization parameters.
Installation
The StatsPack package shouldn’t be installed on the SYSTEM tablespace. Use a separate
tablespace for it using the default initial and next extent size of 1 Mbytes. The minimum
default space requirement is approximately 60 Mbytes, however the amount of space
required is difficult to estimate because it is based on the amount of data collected, the
size of the database and also the instance. You should create the temporary and
permanent tablespace to install the StatsPack before because if you install it on
interactive mode, you will be prompted to input those tablespaces (the tablespaces that
will be used by PERFSTAT user).
The installation of StatsPack can only be done with SQL*Plus because of special
commands used on the scripts. To install StatsPack, a script should be run:
Oracle 8.1.6
Connect / as sysdba
Unix
@?/rdbms/admin/statscre
Connect / as sysdba
NT
@%ORACLE_HOME%\rdbms\admin\statscre
Unix
Oracle 8.1.7 and 9i
Connect / as sysdba
@?/rdbms/admin/spcreate
Connect / as sysdba
NT
@%ORACLE_HOME%\rdbms\admin\spcreate
The StatsPack package script installation runs other 3 scripts and their log is spooled
during the installation with the extension .lis. The status of each of this scripts should be
checked:
If there is a problem during the installation, you can remove the StatsPack and try to
reinstall. In order to do so, run the script:
Oracle 8.1.6
Connect / as sysdba
Unix
@?/rdbms/admin/statsdrp
Connect / as sysdba
NT
@%ORACLE_HOME%\rdbms\admin\statsdrp
Oracle 8.1.7 and 9i
Unix
Connect / as sysdba
@?/rdbms/admin/spdrop
Connect / as sysdba
NT
@%ORACLE_HOME%\rdbms\admin\spdrop
You can also install StatsPack in batch mode by defining the tablespaces (permanent and
temporary) that will be used for PERFSTAT user. For example:
Connect / as sysdba
Define default_tablespace = ‘tools’
Define temporary_tablespace = ‘temp’
For changing the threshold values, two actions can be taken. The first one is through the
statspack.snap procedure, like below:
The i_snap_level was changed but just for this snapshot taken. The next snapshot that
will be taken will have the default values.
The other action for changing the threshold values is through the
statspack.modify_statspack_parameter routine, like below:
execute statspack.modify_statspack_parameter
(i_snap_level=>10, i_buffer_gets_th=>10000, i_disk_reads_th=>1000);
spool spauto.lis
-- Schedule a snapshot to be run on this instance every
-- hour, on the hour
prompt
prompt Job number for automated statistics collection for
prompt this instance
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt Note that this job number is needed when modifying
prompt or removing prompt the job:
print jobno
prompt
prompt Job queue process
prompt ~~~~~~~~~~~~~~~~~
prompt Below is the current setting of the
prompt job_queue_processes init.ora prompt parameter
prompt - the value for this parameter must be greater
prompt than 0 to use automatic statistics gathering:
show parameter job_queue_processes
prompt
prompt
prompt Next scheduled run
prompt ~~~~~~~~~~~~~~~~~~
prompt The next scheduled run for this job is:
select job, next_date, next_sec
from user_jobs
where job = :jobno;
spool off;
DBMS_JOB.REMOVE (
job IN BINARY_INTEGER );
Connect / as sysdba
Unix
@?/rdbms/admin/statsrep
Connect / as sysdba
NT
@%ORACLE_HOME%\rdbms\admin\statsrep
Unix
Oracle 8.1.7 and 9i
Connect / as sysdba
@?/rdbms/admin/spreport
Connect / as sysdba
NT @%ORACLE_HOME%\rdbms\admin\spreport
1.4 Maintenance
In order to remove snapshots from the schema, there is a script called sppurge, available
in Oracle version 8.1.7 and upper that is located on $ORACLE_HOME/rdbms/admin.
1.5 Views
Perfstat user has the following tables that can be queried in order to get information about
snapshots:
STATS$BG_EVENT_SUMMARY
STATS$BUFFER_POOL_STATISTICS
STATS$DATABASE_INSTANCE
STATS$ENQUEUESTAT
STATS$FILESTATXS
STATS$IDLE_EVENT
STATS$LATCH
STATS$LATCH_CHILDREN
STATS$LATCH_MISSES_SUMMARY
STATS$LATCH_PARENT
STATS$LEVEL_DESCRIPTION
STATS$LIBRARYCACHE
STATS$PARAMETER
STATS$ROLLSTAT
STATS$ROWCACHE_SUMMARY
STATS$SESSION_EVENT
STATS$SESSTAT
STATS$SGA
STATS$SGASTAT
STATS$SNAPSHOT
STATS$SQLTEXT
STATS$SQL_STATISTICS
STATS$SQL_SUMMARY
STATS$STATSPACK_PARAMETER
STATS$SYSSTAT
STATS$SYSTEM_EVENT
STATS$TEMPSTATXS
STATS$WAITSTAT