Package STATSPACK

Hello folks
I have the invalid package PERFSTAT.STATSPACK because the error Compilation errors for PACKAGE BODY PERFSTAT.STATSPACK because the errorr: PL/SQL: ORA-00980: synonym translation is no longer valid stats$x$ksppsv sv
Someone has an idea?
Tks
Spaulonci

It sounds like you upgraded your database but did not upgrade the statspack package.
Look to see if you have any recent sp data - look in stats$snapshot
There are upgrade scripts provided in $ORACLE_HOME/rdbms/admin/spup*.sql
If you are on 10g, try looking at AWR data - it's much like statspack and is enabled by default.
I usually disable statspack collection after upgrading to 10g and just use AWR data (e.g. dba_hist_*)
for a standard AWR report run $ORACLE_HOME/rdbms/admin/awrrpt.sql
Cheers

Similar Messages

  • Not able to install Statspack.

    DB 9.2.0.5.0
    OS WIn 2003 server
    I've gone through the following procedure to generate a statspack report. but, I am not able to insatall statspack, though the same procedure worked in 10g.
    1. create a perfstat tablespace
    2. run spcreate.sql
    SPCUSR complete. Please check spcusr.lis for any errors.
    SQL>
    SQL> --
    SQL> -- Build the tables and synonyms
    SQL> connect perfstat/&&perfstat_password
    ERROR:
    ORA-12560: TNS:protocol adapter error
    Warning: You are no longer connected to ORACLE.
    SQL> @@spctab
    SQL> Rem
    SQL> Rem $Header: spctab.sql 16-apr-2002.14:54:46 vbarrier Exp $
    SQL> Rem
    SQL> Rem spctab.sql
    SQL> Rem
    SQL> Rem Copyright (c) 1999, 2002, Oracle Corporation. All rights reserved.
    SQL> Rem
    SQL> Rem NAME
    SQL> Rem spctab.sql
    SQL> Rem
    SQL> Rem DESCRIPTION
    SQL> Rem SQL*PLUS command file to create tables to hold
    SQL> Rem start and end "snapshot" statistical information
    SQL> Rem
    SQL> Rem NOTES
    SQL> Rem Should be run as STATSPACK user, PERFSTAT
    SQL> Rem
    SQL> Rem MODIFIED (MM/DD/YY)
    SQL> Rem vbarrier 03/20/02 - 2143634
    SQL> Rem vbarrier 03/05/02 - Segment Statistics
    SQL> Rem cdialeri 02/07/02 - 2218573
    SQL> Rem cdialeri 01/30/02 - 2184717
    SQL> Rem cdialeri 01/11/02 - 9.2 - features 2
    SQL> Rem cdialeri 11/30/01 - 9.2 - features 1
    SQL> Rem cdialeri 04/22/01 - Undostat changes
    SQL> Rem cdialeri 03/02/01 - 9.0
    SQL> Rem cdialeri 09/12/00 - sp_1404195
    SQL> Rem cdialeri 04/07/00 - 1261813
    SQL> Rem cdialeri 03/20/00 - Support for purge
    SQL> Rem cdialeri 02/16/00 - 1191805
    SQL> Rem cdialeri 01/26/00 - 1169401
    SQL> Rem cdialeri 11/01/99 - Enhance, 1059172
    SQL> Rem cmlim 07/17/97 - Added STATS$SQLAREA to store top sql stmts
    SQL> Rem gwood 10/16/95 - Version to run as sys without using many vi
    SQL> Rem cellis.uk 11/15/89 - Created
    SQL> Rem
    SQL>
    SQL> set showmode off echo off;
    If this script is automatically called from spcreate (which is
    the supported method), all STATSPACK segments will be created in
    the PERFSTAT user's default tablespace.
    Using perfstat tablespace to store Statspack objects
    ... Creating STATS$SNAPSHOT_ID Sequence
    SP2-0640: Not connected
    SP2-0640: Not connected
    ... Creating STATS$... tables
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0640: Not connected
    NOTE:
    SPCTAB complete. Please check spctab.lis for any errors.
    SQL> -- Create the statistics Package
    SQL> @@spcpkg
    SQL> Rem
    SQL> Rem $Header: spcpkg.sql 17-apr-2002.16:59:10 vbarrier Exp $
    SQL> Rem
    SQL> Rem spcpkg.sql
    SQL> Rem
    SQL> Rem Copyright (c) 1999, 2002, Oracle Corporation. All rights reserved.
    SQL> Rem
    SQL> Rem NAME
    SQL> Rem spcpkg.sql
    SQL> Rem
    SQL> Rem DESCRIPTION
    SQL> Rem SQL*PLUS command file to create statistics package
    SQL> Rem
    SQL> Rem NOTES
    SQL> Rem Must be run as the STATSPACK owner, PERFSTAT
    SQL> Rem
    SQL> Rem MODIFIED (MM/DD/YY)
    SQL> Rem vbarrier 03/20/02 - 2184504
    SQL> Rem spommere 03/19/02 - 2274095
    SQL> Rem vbarrier 03/05/02 - Segment Statistics
    SQL> Rem spommere 02/14/02 - cleanup RAC stats that are no longer needed
    SQL> Rem spommere 02/08/02 - 2212357
    SQL> Rem cdialeri 02/07/02 - 2218573
    SQL> Rem cdialeri 01/30/02 - 2184717
    SQL> Rem cdialeri 01/09/02 - 9.2 - features 2
    SQL> Rem cdialeri 11/30/01 - 9.2 - features 1
    SQL> Rem hbergh 08/23/01 - 1940915: use substrb on sql_text
    SQL> Rem cdialeri 04/26/01 - 9.0
    SQL> Rem cdialeri 09/12/00 - sp_1404195
    SQL> Rem cdialeri 04/07/00 - 1261813
    SQL> Rem cdialeri 03/28/00 - sp_purge
    SQL> Rem cdialeri 02/16/00 - 1191805
    SQL> Rem cdialeri 11/01/99 - Enhance, 1059172
    SQL> Rem cgervasi 06/16/98 - Remove references to wrqs
    SQL> Rem cmlim 07/30/97 - Modified system events
    SQL> Rem gwood.uk 02/30/94 - Modified
    SQL> Rem densor.uk 03/31/93 - Modified
    SQL> Rem cellis.uk 11/15/89 - Created
    SQL> Rem
    SQL>
    SQL> set echo off;
    Creating Package STATSPACK...
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0641: "SHOW ERRORS" requires connection to server
    Creating Package Body STATSPACK...
    SP2-0640: Not connected
    SP2-0640: Not connected
    SP2-0641: "SHOW ERRORS" requires connection to server
    NOTE:
    SPCPKG complete. Please check spcpkg.lis for any errors.
    hare krishna
    Alok

    Hi Alok
    I have encountered this before
    In the script there will be a comnnection link at the spcreate sql..
    Rem
    Rem $Header: spcreate.sql 16-apr-2002.11:22:55 vbarrier Exp $
    Rem
    Rem spcreate.sql
    Rem
    Rem Copyright (c) 1999, 2002, Oracle Corporation.  All rights reserved. 
    Rem
    Rem    NAME
    Rem      spcreate.sql - Statistics Create
    Rem
    Rem    DESCRIPTION
    Rem      SQL*PLUS command file which creates the STATSPACK user,
    Rem      tables and package for the performance diagnostic tool STATSPACK
    Rem
    Rem    NOTES
    Rem      Note the script connects INTERNAL and so must be run from
    Rem      an account which is able to connect internal.
    Rem
    Rem    MODIFIED   (MM/DD/YY)
    Rem    cdialeri    02/16/00 - 1191805
    Rem    cdialeri    12/06/99 - 1103031
    Rem    cdialeri    08/13/99 - Created
    Rem
    --  Create PERFSTAT user and required privileges
    @@spcusr
    --  Build the tables and synonyms
    connect perfstat/&&perfstat_password@MARAN
    @@spctab
    --  Create the statistics Package
    @@spcpkgadd the @servicename and run the script
    It will work
    Message was edited by:
    Maran Viswarayar

  • Error occured when installing the statspack

    1.create tablespaces: sp_data,sp_indx,sp_temp.
    sp_temp is used for temporary space,but i made a mistake: set sp_temp a permanence tablespace.
    2.sql>@spcreate.sql
    error
    3.sql>@spdrop.sql
    4.drop user perfstat cascade
    5.drop tablespace sp_temp
    6.create temporary tablespce sp_temp
    7.sql>@spcreate.sql
    then ------------------>
    Stopped spooling to E:\plsqldev\crack\spctab.lis
    Started spooling to E:\plsqldev\crack\spcpkg.lis
    Creating Package STATSPACK...
    Package created
    No errors for PACKAGE PERFSTAT.STATSPACK
    Creating Package Body STATSPACK...
    Warning: Package body created with compilation errors
    Errors for PACKAGE BODY PERFSTAT.STATSPACK:
    LINE/COL ERROR
    329/19 PL/SQL: ORA-00980: synonym translation is no longer valid
    291/12 PL/SQL: SQL Statement ignored
    335/26 PL/SQL: ORA-00980: synonym translation is no longer valid
    335/14 PL/SQL: SQL Statement ignored
    431/19 PL/SQL: ORA-00980:synonym translation is no longer valid
    431/12 PL/SQL: SQL Statement ignored
    494/28 PL/SQL: ORA-00980: synonym translation is no longer 94/16 PL/SQL: SQL Statement ignored
    672/20 PL/SQL: ORA-00980: synonym translation is no longer valid
    671/13 PL/SQL: SQL Statement ignored
    HOW CAN I DEAL WITH IT?

    The error means "The synonym used is based on a table, view, or synonym that no longer exists." It is possible create a synonym for non-existing objects and objects of non-existing users. When tables are dropped, synonyms owned by other users still point to the objects.
    I recoomend you to do the installation of statspack freeshly and cleanly.

  • Error while creating statspack

    i m practicing to create Statspack report
    oracle 9.2 on windows
    i created a database with the name bkp2. listener up and running.
    i had never run the spcreate.sql in this db before
    when i did run it i got the below error
    Creating Package STATSPACK...
    Package created.
    No errors.
    Creating Package Body STATSPACK...
    Warning: Package Body created with compilation errors.
    Errors for PACKAGE BODY STATSPACK:
    LINE/COL ERROR                                                                 
    1655/6   PL/SQL: SQL Statement ignored                                         
    1657/13  PL/SQL: ORA-00942: table or view does not exist                       
    1685/11  PL/SQL: SQL Statement ignored                                         
    1705/22  PL/SQL: ORA-00942: table or view does not exist                       
    NOTE:
    SPCPKG complete. Please check spcpkg.lis for any errors.the code is running successfully till it starts creating the statspack package body. the tablespace and temp file which is given for the perfstat user have more than 200MB space.
    interestingly when i create the same with another database in the system created both through manual and dbca, it runs perfectly.
    i dont want the direct solution for this. i jus want to know how i can find out the cause for this. i tried to trace the session i.e. alter session set sql_trace=true;
    still i didnt understand how to go about from there and when i searched the error in the trace it didnt appear there!! ... so in such cases how do i pinpoint which statement is causing the error. the line no. is not of much use as the whole code is full of comments in between !!
    thank you

    i m using SYSDBA user only ...
    code:
    conn sys as sysdba
    added:
    i v also run spdrop.sql as SYSDBA and tried to re-run the spcreate.sql script several times in this database. still same results. i wonder why this happens jus to this db
    i v also created a new tablespace which is not used by any other user objects. and a new temp tablespace and used them while running the spcreate.sql
    still same results.
    Edited by: iinfi on Oct 31, 2008 8:43 PM

  • Lots of ORA- in my alertPROD.log

    Hi,
    EBS 11i (11.5.10.2)
    RHEL 4.6
    I browsed our database alert logs and I see lots of following:
    1)
    ORA-01555 caused by SQL statement below (Query Duration=1286790742 sec, SCN: 0x056d.6f011aeb):
    Mon Oct 11 17:52:22 2010
    SELECT TO_CHAR(REQUEST_DATE,'MM/DD/YYYY') FROM APPS.OE_ORDER_HEADERS_ALL WHERE TO_CHAR(ORDER_NUMBER) = :B1
    2)
    ORA-1652: unable to extend temp segment by 212992 in tablespace SYSTEM
    3)
    ORA-07445: exception encountered: core dump [ptmak()+106] [SIGSEGV] [Address not mapped to object] [0x8] [] []
    Mon Oct 18 17:27:57 2010
    4)
    WARNING:Oracle instance running on a system with low open file descriptor
    limit. Tune your system to increase this limit to avoid
    severe performance degradation.
    Have you seen this in your alert logs too?
    How do you resolve this errors please....
    Thanks a lot,
    Ms K

    Hi hussein/Helios
    My DB is 9.2.0.6 for EBS 11i
    I am now installing Statspack, using the command
    SQL> connect / as sysdba
    SQL> @?/rdbms/admin/spcreate
    NOTE:
    SPCTAB complete. Please check spctab.lis for any errors.
    SQL> --  Create the statistics Package
    SQL> @@spcpkg
    SQL> Rem
    SQL> Rem $Header: spcpkg.sql 10-may-2004.15:32:48 cdialeri Exp $
    SQL> Rem
    SQL> Rem spcpkg.sql
    SQL> Rem
    SQL> Rem Copyright (c) 1999, 2004, Oracle. All rights reserved.
    SQL> Rem
    SQL> Rem    NAME
    SQL> Rem         spcpkg.sql
    SQL> Rem
    SQL> Rem    DESCRIPTION
    SQL> Rem         SQL*PLUS command file to create statistics package
    SQL> Rem
    SQL> Rem    NOTES
    SQL> Rem         Must be run as the STATSPACK owner, PERFSTAT
    SQL> Rem
    SQL> Rem    MODIFIED   (MM/DD/YY)
    SQL> Rem    cdialeri    05/10/04 - 3566569
    SQL> Rem    vbarrier    03/20/02 - 2184504
    SQL> Rem    spommere    03/19/02 - 2274095
    SQL> Rem    vbarrier    03/05/02 - Segment Statistics
    SQL> Rem    spommere    02/14/02 - cleanup RAC stats that are no longer needed
    SQL> Rem    spommere    02/08/02 - 2212357
    SQL> Rem    cdialeri    02/07/02 - 2218573
    SQL> Rem    cdialeri    01/30/02 - 2184717
    SQL> Rem    cdialeri    01/09/02 - 9.2 - features 2
    SQL> Rem    cdialeri    11/30/01 - 9.2 - features 1
    SQL> Rem    hbergh      08/23/01 - 1940915: use substrb on sql_text
    SQL> Rem    cdialeri    04/26/01 - 9.0
    SQL> Rem    cdialeri    09/12/00 - sp_1404195
    SQL> Rem    cdialeri    04/07/00 - 1261813
    SQL> Rem    cdialeri    03/28/00 - sp_purge
    SQL> Rem    cdialeri    02/16/00 - 1191805
    SQL> Rem    cdialeri    11/01/99 - Enhance, 1059172
    SQL> Rem    cgervasi    06/16/98 - Remove references to wrqs
    SQL> Rem    cmlim       07/30/97 - Modified system events
    SQL> Rem    gwood.uk    02/30/94 - Modified
    SQL> Rem    densor.uk   03/31/93 - Modified
    SQL> Rem    cellis.uk   11/15/89 - Created
    SQL> Rem
    SQL>
    SQL> set echo off;
    Creating Package STATSPACK...
    Package created.
    No errors.
    Creating Package Body STATSPACK...
    Package body created.
    No errors.
    NOTE:
    SPCPKG complete. Please check spcpkg.lis for any errors.
    SQL>I got those logs above ... Is the installation of STATSPACK completed? It left hanging on SQL> prompt.
    Thanks,

  • Package.......StatsPack...Error..

    Hi.. i m tuning my Oracle Database, for that i need to install Statspack package, when i compiled package... it returned following error.
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY STATSPACK:
    LINE/COL ERROR
    2045/3 PLS-00201: identifier 'SYS.DBMS_SHARED_POOL' must be declared
    2045/3 PL/SQL: Statement ignored
    HOw to solve above error..Please check the following Package, and do help me.
    Note: I m connected perfstat user, no as SYS user.
    create or replace package body STATSPACK as
    /* Define package variables.
    Variables prefixed with p_ are package variables.
    p_snap_id integer; /* snapshot id */
    p_instance_number number; /* instance number */
    p_instance_name varchar2(16); /* instance name */
    p_startup_time date; /* instance startup time */
    p_parallel varchar2(3); /* parallel server */
    p_version varchar2(17); /* Oracle release */
    p_dbid number; /* database id */
    p_host_name varchar2(64); /* host instance is on */
    p_name varchar2(9); /* database name */
    p_new_sga integer; /* Instance bounced since last snap? */
    tmp_int integer; /* initialise defaults */
    p_def_snap_level number default 5; /* default snapshot lvl */
    p_def_session_id number default 0; /* default session id */
    p_def_ucomment varchar2(160) default null;
    p_def_pin_statspack varchar2(10) default 'TRUE';
    p_def_last_modified date default SYSDATE;
    /* Below are the default threshold (_th) values for choosing SQL statements
    to store in the stats$sqlsummary table - these statements will typically
    be the statements using the most resources.
    p_def_num_sql number default 50; /* Num. SQL statements */
    p_def_executions_th number default 100; /* Num. executions */
    p_def_parse_calls_th number default 1000; /* Num. parse calls */
    p_def_disk_reads_th number default 1000; /* Num. disk reads */
    p_def_buffer_gets_th number default 10000; /* Num. buf gets */
    p_def_sharable_mem_th number default 1048576; /* Sharable memory */
    p_def_version_count_th number default 20; /* Child Cursors */
    p_def_all_init varchar2(10) default 'FALSE';
    cursor get_instance is
    select instance_number, instance_name
    , startup_time, parallel, version
    , host_name
    from v$instance;
    cursor get_db is
    select dbid, name
    from v$database;
    procedure SNAP
    (i_snap_level in number default null
    ,i_session_id in number default null
    ,i_ucomment in varchar2 default null
    ,i_num_sql in number default null
    ,i_executions_th in number default null
    ,i_parse_calls_th in number default null
    ,i_disk_reads_th in number default null
    ,i_buffer_gets_th in number default null
    ,i_sharable_mem_th in number default null
    ,i_version_count_th in number default null
    ,i_all_init in varchar2 default null
    ,i_pin_statspack in varchar2 default null
    ,i_modify_parameter in varchar2 default 'FALSE'
    is
    /* Takes a snapshot by calling the SNAP function, and discards
    the snapshot id. This is useful when automating taking
    snapshots from dbms_job
    l_snap_id number;
    begin
    l_snap_id := statspack.snap ( i_snap_level, i_session_id, i_ucomment
    , i_num_sql
    , i_executions_th
    , i_parse_calls_th
    , i_disk_reads_th
    , i_buffer_gets_th
    , i_sharable_mem_th
    , i_version_count_th
    , i_all_init
    , i_pin_statspack
    , i_modify_parameter);
    end SNAP;
    procedure MODIFY_STATSPACK_PARAMETER
    ( i_dbid in number default null
    , i_instance_number in number default null
    , i_snap_level in number default null
    , i_session_id in number default null
    , i_ucomment in varchar2 default null
    , i_num_sql in number default null
    , i_executions_th in number default null
    , i_parse_calls_th in number default null
    , i_disk_reads_th in number default null
    , i_buffer_gets_th in number default null
    , i_sharable_mem_th in number default null
    , i_version_count_th in number default null
    , i_all_init in varchar2 default null
    , i_pin_statspack in varchar2 default null
    , i_modify_parameter in varchar2 default 'TRUE'
    is
    /* Calls QAM with the modify flag, and discards the
    output variables
    l_snap_level number;
    l_session_id number;
    l_ucomment varchar2(160);
    l_num_sql number;
    l_executions_th number;
    l_parse_calls_th number;
    l_disk_reads_th number;
    l_buffer_gets_th number;
    l_sharable_mem_th number;
    l_version_count_th number;
    l_all_init varchar2(5);
    l_pin_statspack varchar2(10);
    begin
    statspack.qam_statspack_parameter( i_dbid
    , i_instance_number
    , i_snap_level
    , i_session_id
    , i_ucomment
    , i_num_sql
    , i_executions_th
    , i_parse_calls_th
    , i_disk_reads_th
    , i_buffer_gets_th
    , i_sharable_mem_th
    , i_version_count_th
    , i_all_init
    , i_pin_statspack
    , 'TRUE'
    , l_snap_level
    , l_session_id
    , l_ucomment
    , l_num_sql
    , l_executions_th
    , l_parse_calls_th
    , l_disk_reads_th
    , l_buffer_gets_th
    , l_sharable_mem_th
    , l_version_count_th
    , l_all_init
    , l_pin_statspack);
    /* As we have explicity been requested to change the parameters,
    independently of taking a snapshot, commit
    commit;
    end MODIFY_STATSPACK_PARAMETER;
    procedure QAM_STATSPACK_PARAMETER
    ( i_dbid in number default null
    , i_instance_number in number default null
    , i_snap_level in number default null
    , i_session_id in number default null
    , i_ucomment in varchar2 default null
    , i_num_sql in number default null
    , i_executions_th in number default null
    , i_parse_calls_th in number default null
    , i_disk_reads_th in number default null
    , i_buffer_gets_th in number default null
    , i_sharable_mem_th in number default null
    , i_version_count_th in number default null
    , i_all_init in varchar2 default null
    , i_pin_statspack in varchar2 default null
    , i_modify_parameter in varchar2 default 'FALSE'
    , o_snap_level out number
    , o_session_id out number
    , o_ucomment out varchar2
    , o_num_sql out number
    , o_executions_th out number
    , o_parse_calls_th out number
    , o_disk_reads_th out number
    , o_buffer_gets_th out number
    , o_sharable_mem_th out number
    , o_version_count_th out number
    , o_all_init out varchar2
    , o_pin_statspack out varchar2
    is
    /* Query And Modify statspack parameter procedure, allows query
    and/or user modification of the statistics collection parameters
    for an instance. If there are no pre-existing parameters for
    an instance, insert the Oracle defaults.
    l_instance_number number;
    l_dbid number;
    ui_all_init varchar2(5);
    l_params_exist varchar2(1);
    begin
    if ((i_dbid is null ) or (i_instance_number is null)) then
    l_dbid := p_dbid;
    l_instance_number := p_instance_number;
    else
    l_dbid := i_dbid;
    l_instance_number := i_instance_number;
    end if;
    /* Upper case any input vars which are inserted */
    ui_all_init := upper(i_all_init);
    if ( (i_modify_parameter is null)
    or (upper(i_modify_parameter) = 'FALSE') ) then
    /* Query values, if none exist, insert the defaults tempered
    with variables supplied */
    begin
    select nvl(i_session_id, session_id)
    , nvl(i_snap_level, snap_level)
    , nvl(i_ucomment, ucomment)
    , nvl(i_num_sql, num_sql)
    , nvl(i_executions_th, executions_th)
    , nvl(i_parse_calls_th, parse_calls_th)
    , nvl(i_disk_reads_th, disk_reads_th)
    , nvl(i_buffer_gets_th, buffer_gets_th)
    , nvl(i_sharable_mem_th, sharable_mem_th)
    , nvl(i_version_count_th, version_count_th)
    , nvl(ui_all_init, all_init)
    , nvl(i_pin_statspack, pin_statspack)
    into o_session_id
    , o_snap_level
    , o_ucomment
    , o_num_sql
    , o_executions_th
    , o_parse_calls_th
    , o_disk_reads_th
    , o_buffer_gets_th
    , o_sharable_mem_th
    , o_version_count_th
    , o_all_init
    , o_pin_statspack
    from stats$statspack_parameter
    where instance_number = l_instance_number
    and dbid = l_dbid;
    exception
    when NO_DATA_FOUND then
    insert into stats$statspack_parameter
    ( dbid
    , instance_number
    , session_id
    , snap_level
    , ucomment
    , num_sql
    , executions_th
    , parse_calls_th
    , disk_reads_th
    , buffer_gets_th
    , sharable_mem_th
    , version_count_th
    , all_init
    , pin_statspack
    , last_modified
    values
    ( l_dbid
    , l_instance_number
    , p_def_session_id
    , p_def_snap_level
    , p_def_ucomment
    , p_def_num_sql
    , p_def_executions_th
    , p_def_parse_calls_th
    , p_def_disk_reads_th
    , p_def_buffer_gets_th
    , p_def_sharable_mem_th
    , p_def_version_count_th
    , p_def_all_init
    , p_def_pin_statspack
    , SYSDATE
    returning nvl(i_session_id, p_def_session_id)
    , nvl(i_snap_level, p_def_snap_level)
    , nvl(i_ucomment, p_def_ucomment)
    , nvl(i_num_sql, p_def_num_sql)
    , nvl(i_executions_th, p_def_executions_th)
    , nvl(i_parse_calls_th, p_def_parse_calls_th)
    , nvl(i_disk_reads_th, p_def_disk_reads_th)
    , nvl(i_buffer_gets_th, p_def_buffer_gets_th)
    , nvl(i_sharable_mem_th, p_def_sharable_mem_th)
    , nvl(i_version_count_th, p_def_version_count_th)
    , nvl(ui_all_init, p_def_all_init)
    , nvl(i_pin_statspack, p_def_pin_statspack)
    into o_session_id
    , o_snap_level
    , o_ucomment
    , o_num_sql
    , o_executions_th
    , o_parse_calls_th
    , o_disk_reads_th
    , o_buffer_gets_th
    , o_sharable_mem_th
    , o_version_count_th
    , o_all_init
    , o_pin_statspack;
    end; /* don't modify parameter values */
    elsif upper(i_modify_parameter) = 'TRUE' then
    /* modify values, if none exist, insert the defaults tempered
    with the variables supplied */
    begin
    update stats$statspack_parameter
    set session_id = nvl(i_session_id, session_id)
    , snap_level = nvl(i_snap_level, snap_level)
    , ucomment = nvl(i_ucomment, ucomment)
    , num_sql = nvl(i_num_sql, num_sql)
    , executions_th = nvl(i_executions_th, executions_th)
    , parse_calls_th = nvl(i_parse_calls_th, parse_calls_th)
    , disk_reads_th = nvl(i_disk_reads_th, disk_reads_th)
    , buffer_gets_th = nvl(i_buffer_gets_th, buffer_gets_th)
    , sharable_mem_th = nvl(i_sharable_mem_th, sharable_mem_th)
    , version_count_th = nvl(i_version_count_th, version_count_th)
    , all_init = nvl(ui_all_init, all_init)
    , pin_statspack = nvl(i_pin_statspack, pin_statspack)
    where instance_number = l_instance_number
    and dbid = l_dbid
    returning session_id
    , snap_level
    , ucomment
    , num_sql
    , executions_th
    , parse_calls_th
    , disk_reads_th
    , buffer_gets_th
    , sharable_mem_th
    , version_count_th
    , all_init
    , pin_statspack
    into o_session_id
    , o_snap_level
    , o_ucomment
    , o_num_sql
    , o_executions_th
    , o_parse_calls_th
    , o_disk_reads_th
    , o_buffer_gets_th
    , o_sharable_mem_th
    , o_version_count_th
    , o_all_init
    , o_pin_statspack;
    if SQL%ROWCOUNT = 0 then
    insert into stats$statspack_parameter
    ( dbid
    , instance_number
    , session_id
    , snap_level
    , ucomment
    , num_sql
    , executions_th
    , parse_calls_th
    , disk_reads_th
    , buffer_gets_th
    , sharable_mem_th
    , version_count_th
    , all_init
    , pin_statspack
    , last_modified
    values
    ( l_dbid
    , l_instance_number
    , nvl(i_session_id, p_def_session_id)
    , nvl(i_snap_level, p_def_snap_level)
    , nvl(i_ucomment, p_def_ucomment)
    , nvl(i_num_sql, p_def_num_sql)
    , nvl(i_executions_th, p_def_executions_th)
    , nvl(i_parse_calls_th, p_def_parse_calls_th)
    , nvl(i_disk_reads_th, p_def_disk_reads_th)
    , nvl(i_buffer_gets_th, p_def_buffer_gets_th)
    , nvl(i_sharable_mem_th, p_def_sharable_mem_th)
    , nvl(i_version_count_th, p_def_version_count_th)
    , nvl(ui_all_init, p_def_all_init)
    , nvl(i_pin_statspack, p_def_pin_statspack)
    , SYSDATE
    returning session_id
    , snap_level
    , ucomment
    , num_sql
    , executions_th
    , parse_calls_th
    , disk_reads_th
    , buffer_gets_th
    , sharable_mem_th
    , version_count_th
    , all_init
    , pin_statspack
    into o_session_id
    , o_snap_level
    , o_ucomment
    , o_num_sql
    , o_executions_th
    , o_parse_calls_th
    , o_disk_reads_th
    , o_buffer_gets_th
    , o_sharable_mem_th
    , o_version_count_th
    , o_all_init
    , o_pin_statspack;
    end if;
    end; /* modify values */
    else
    /* error */
    raise_application_error
    (-20100,'QAM_STATSPACK_PARAMETER i_modify_parameter value is invalid');
    end if; /* modify */
    end QAM_STATSPACK_PARAMETER;
    procedure STAT_CHANGES
    /* Returns a set of differences of the values from corresponding pairs
    of rows in STATS$SYSSTAT, STATS$LIBRARYCACHE and STATS$WAITSTAT,
    based on the begin and end (bid, eid) snapshot id's specified.
    This procedure is the only call to STATSPACK made by the statsrep
    report.
    Modified to include multi-db support.
    ( bid IN number
    , eid IN number
    , db_ident IN number
    , inst_num IN number
    , parallel IN varchar2
    , lhtr OUT number, bfwt OUT number
    , tran OUT number, chng OUT number
    , ucal OUT number, urol OUT number
    , rsiz OUT number
    , phyr OUT number, phyrd OUT number
    , phyrdl OUT number
    , phyw OUT number, ucom OUT number
    , prse OUT number, hprse OUT number
    , recr OUT number, gets OUT number
    , rlsr OUT number, rent OUT number
    , srtm OUT number, srtd OUT number
    , srtr OUT number, strn OUT number
    , lhr OUT number, bc OUT varchar2
    , sp OUT varchar2, lb OUT varchar2
    , bs OUT varchar2, twt OUT number
    , logc OUT number, prscpu OUT number
    , tcpu OUT number, exe OUT number
    , prsela OUT number
    , bspm OUT number, espm OUT number
    , bfrm OUT number, efrm OUT number
    , blog OUT number, elog OUT number
    , bocur OUT number, eocur OUT number
    , dmsd OUT number, dmfc OUT number -- begin OPS
    , dfcms OUT number, dfcmr OUT number
    , dmsi OUT number, dmrv OUT number
    , dynal OUT number, dynares OUT number
    , pmrv OUT number, pmpt OUT number
    , npmrv OUT number, npmpt OUT number
    , scma OUT number, scml OUT number
    , pinc OUT number, picrnc OUT number
    , picc OUT number, picrcc OUT number
    , pbc OUT number, pbcrc OUT number
    , pcba OUT number, pccrba OUT number
    , pcrbpi OUT number
    , dynapres OUT number, dynapshl OUT number
    , prcma OUT number, prcml OUT number
    , pwrm OUT number, pfpim OUT number
    , pwnm OUT number
    , dpms OUT number, dnpms OUT number
    , glsg OUT number, glag OUT number
    , glgt OUT number, glsc OUT number
    , glac OUT number, glct OUT number
    , glrl OUT number
    , gcge OUT number, gcgt OUT number
    , gccv OUT number, gcct OUT number
    , gccrrv OUT number, gccrrt OUT number
    , gccurv OUT number, gccurt OUT number
    , gccrsv OUT number
    , gccrbt OUT number, gccrft OUT number
    , gccrst OUT number, gccusv OUT number
    , gccupt OUT number, gccuft OUT number
    , gccust OUT number -- end OPS
    ) is
    bval number;
    eval number;
    l_b_session_id number; /* begin session id */
    l_b_serial# number; /* begin serial# */
    l_e_session_id number; /* end session id */
    l_e_serial# number; /* end serial# */
    function LIBRARYCACHE_HITRATIO RETURN number is
    /* Returns Library cache hit ratio for the begin and end (bid, eid)
    snapshot id's specified
    cursor LH (i_snap_id number) is
    select sum(pins), sum(pinhits)
    from stats$librarycache
    where snap_id = i_snap_id
    and dbid = db_ident
    and instance_number = inst_num;
    bpsum number;
    bhsum number;
    epsum number;
    ehsum number;
    begin
    if not LH%ISOPEN then open LH (bid); end if;
    fetch LH into bpsum, bhsum;
    if LH%NOTFOUND then
    raise_application_error
    (-20100,'Missing start value for stats$librarycache');
    end if; close LH;
    if not LH%ISOPEN then open LH (eid); end if;
    fetch LH into epsum, ehsum;
    if LH%NOTFOUND then
    raise_application_error
    (-20100,'Missing end value for stats$librarycache');
    end if; close LH;
    return (ehsum - bhsum) / (epsum - bpsum);
    end LIBRARYCACHE_HITRATIO;
    function GET_PARAM (i_name varchar2) RETURN varchar2 is
    /* Returns the value for the init.ora parameter for the snapshot
    specified.
    cursor PARAMETER is
    select value
    from stats$parameter
    where snap_id = eid
    and dbid = db_ident
    and instance_number = inst_num
    and name = i_name;
    par_value varchar2(512);
    begin
    if not PARAMETER%ISOPEN then open PARAMETER; end if;
    fetch PARAMETER into par_value;
    if PARAMETER%NOTFOUND then
    raise_application_error
    (-20100,'Missing Init.ora parameter '|| i_name);
    end if; close PARAMETER;
    return par_value;
    end GET_PARAM;
    function GET_SYSSTAT (i_name varchar2, i_beid number) RETURN number is
    /* Returns the value for the System Statistic for the snapshot
    specified.
    cursor SYSSTAT is
    select value
    from stats$sysstat
    where snap_id = i_beid
    and dbid = db_ident
    and instance_number = inst_num
    and name = i_name;
    stat_value varchar2(512);
    begin
    if not SYSSTAT%ISOPEN then open SYSSTAT; end if;
    fetch SYSSTAT into stat_value;
    if SYSSTAT%NOTFOUND then
    raise_application_error
    (-20100,'Missing System Statistic '|| i_name);
    end if; close SYSSTAT;
    return stat_value;
    end GET_SYSSTAT;
    function BUFFER_WAITS RETURN number is
    /* Returns the total number of waits for all buffers in the interval
    specified by the begin and end snapshot id's (bid, eid)
    cursor BW (i_snap_id number) is
    select sum(wait_count)
    from stats$waitstat
    where snap_id = i_snap_id
    and dbid = db_ident
    and instance_number = inst_num;
    bbwsum number; ebwsum number;
    begin
    if not BW%ISOPEN then open BW (bid); end if;
    fetch BW into bbwsum;
    if BW%NOTFOUND then
    raise_application_error
    (-20100,'Missing start value for stats$waitstat');
    end if; close BW;
    if not BW%ISOPEN then open BW (eid); end if;
    fetch BW into ebwsum;
    if BW%NOTFOUND then
    raise_application_error
    (-20100,'Missing end value for stats$waitstat');
    end if; close BW;
    return ebwsum - bbwsum;
    end BUFFER_WAITS;
    function TOTAL_EVENT_TIME RETURN number is
    /* Returns the total amount of time waited for events for
    the interval specified by the begin and end snapshot id's
    (bid, eid) by foreground processes. This excludes idle
    wait events.
    cursor WAITS (i_snap_id number) is
    select sum(time_waited_micro)
    from stats$system_event
    where snap_id = i_snap_id
    and dbid = db_ident
    and instance_number = inst_num
    and event not in (select event from stats$idle_event);
    bwaittime number;
    ewaittime number;
    begin
    if not WAITS%ISOPEN then open WAITS (bid); end if;
    fetch WAITS into bwaittime;
    if WAITS%NOTFOUND then
    raise_application_error
    (-20100,'Missing start value for stats$system_event');
    end if; close WAITS;
    if not WAITS%ISOPEN then open WAITS (eid); end if;
    fetch WAITS into ewaittime;
    if WAITS%NOTFOUND then
    raise_application_error
    (-20100,'Missing end value for stats$system_event');
    end if; close WAITS;
    return ewaittime - bwaittime;
    end TOTAL_EVENT_TIME;
    function LATCH_HITRATIO return NUMBER is
    /* Returns the latch hit ratio specified by the begin and
    end snapshot id's (bid, eid)
    cursor GETS_MISSES (i_snap_id number) is
    select sum(gets), sum(misses)
    from stats$latch
    where snap_id = i_snap_id
    and dbid = db_ident
    and instance_number = inst_num;
    blget number; -- beginning latch gets
    blmis number; -- beginning latch misses
    elget number; -- end latch gets
    elmis number; -- end latch misses
    begin
    if not GETS_MISSES%ISOPEN then open GETS_MISSES (bid); end if;
    fetch GETS_MISSES into blget, blmis;
    if GETS_MISSES%NOTFOUND then
    raise_application_error
    (-20100,'Missing start value for STATS$LATCH gets and misses');
    end if; close GETS_MISSES;
    if not GETS_MISSES%ISOPEN then open GETS_MISSES (eid); end if;
    fetch GETS_MISSES into elget, elmis;
    if GETS_MISSES%NOTFOUND then
    raise_application_error
    (-20100,'Missing end value for STATS$LATCH gets and misses');
    end if; close GETS_MISSES;
    return ( ( elmis - blmis ) / ( elget - blget ) );
    end LATCH_HITRATIO;
    function SGASTAT (i_name varchar2, i_beid number) RETURN number is
    /* Returns the bytes used by i_name in the shared pool
    for the begin or end snapshot (bid, eid) specified
    cursor bytes_used is
    select bytes
    from stats$sgastat
    where snap_id = i_beid
    and dbid = db_ident
    and instance_number = inst_num
    and pool in ('shared pool', 'all pools')
    and name = i_name;
    total_bytes number;
    begin
    if i_name = 'total_shared_pool' then
    select sum(bytes)
    into total_bytes
    from stats$sgastat
    where snap_id = i_beid
    and dbid = db_ident
    and instance_number = inst_num
    and pool in ('shared pool','all pools');
    else
    open bytes_used; fetch bytes_used into total_bytes;
    if bytes_used%notfound then
    raise_application_error
    (-20100,'Missing value for SGASTAT: '||i_name);
    end if;
    close bytes_used;
    end if;
    return total_bytes;
    end SGASTAT;
    function SYSDIF (i_name varchar2) RETURN number is
    /* Returns the difference between statistics for the statistic
    name specified for the interval between the begin and end
    snapshot id's (bid, eid)
    cursor SY (i_snap_id number) is
    select value
    from stats$sysstat
    where snap_id = i_snap_id
    and dbid = db_ident
    and instance_number = inst_num
    and name = i_name;
    begin
    /* Get start value */
    open SY (bid); fetch SY into bval;
    if SY%notfound then
    raise_application_error
    (-20100,'Missing start value for statistic: '||i_name);
    end if; close SY;
    /* Get end value */
    open SY (eid); fetch SY into eval;
    if SY%notfound then
    raise_application_error
    (-20100,'Missing end value for statistic: '||i_name);
    end if; close SY;
    /* Return difference */
    return eval - bval;
    end SYSDIF;
    function SESDIF (st_name varchar2) RETURN number is
    /* Returns the difference between statistics values for the
    statistic name specified for the interval between the begin and end
    snapshot id's (bid, eid), for the session monitored for that
    snapshot
    cursor SE (i_snap_id number) is
    select ses.value
    from stats$sysstat sys
    , stats$sesstat ses
    where sys.snap_id = i_snap_id
    and ses.snap_id = i_snap_id
    and ses.dbid = db_ident
    and sys.dbid = db_ident
    and ses.instance_number = inst_num
    and sys.instance_number = inst_num
    and ses.statistic# = sys.statistic#
    and sys.name = st_name;
    begin
    /* Get start value */
    open SE (bid); fetch SE into bval;
    if SE%notfound then
    eval :=0;
    end if; close SE;
    /* Get end value */
    open SE (eid); fetch SE into eval;
    if SE%notfound then
    eval :=0;
    end if; close SE;
    /* Return difference */
    return eval - bval;
    end SESDIF;
    function DLMDIF (i_name varchar2) RETURN number is
    /* Returns the difference between statistics for the statistic
    name specified for the interval between the begin and end
    snapshot id's (bid, eid)
    cursor DLM (i_snap_id number) is
    select value
    from stats$dlm_misc
    where snap_id = i_snap_id
    and dbid = db_ident
    and instance_number = inst_num
    and name = i_name;
    begin
    /* Get start value */
    open DLM (bid); fetch DLM into bval;
    if DLM%notfound then
    raise_application_error
    (-20100,'Missing start value for statistic: '||i_name);
    end if; close DLM;
    /* Get end value */
    open DLM (eid); fetch DLM into eval;
    if DLM%notfound then
    raise_application_error
    (-20100,'Missing end value for statistic: '||i_name);
    end if; close DLM;
    /* Return difference */
    return eval - bval;
    end DLMDIF;
    begin /* main procedure body of STAT_CHANGES */
    lhtr := LIBRARYCACHE_HITRATIO;
    bfwt := BUFFER_WAITS;
    lhr := LATCH_HITRATIO;
    chng := SYSDIF('db block changes');
    ucal := SYSDIF('user calls');
    urol := SYSDIF('user rollbacks');
    ucom := SYSDIF('user commits');
    tran := ucom + urol;
    rsiz := SYSDIF('redo size');
    phyr := SYSDIF('physical reads');
    phyrd := SYSDIF('physical reads direct');
    phyrdl := SYSDIF('physical reads direct (lob)');
    phyw := SYSDIF('physical writes');
    hprse := SYSDIF('parse count (hard)');
    prse := SYSDIF('parse count (total)');
    gets := SYSDIF('session logical reads');
    recr := SYSDIF('recursive calls');
    rlsr := SYSDIF('redo log space requests');
    rent := SYSDIF('redo entries');
    srtm := SYSDIF('sorts (memory)');
    srtd := SYSDIF('sorts (disk)');
    srtr := SYSDIF('sorts (rows)');
    logc := SYSDIF('logons cumulative');
    prscpu := SYSDIF('parse time cpu');
    prsela := SYSDIF('parse time elapsed');
    tcpu := SYSDIF('CPU used by this session');
    exe := SYSDIF('execute count');
    bs := GET_PARAM('db_block_size');
    bc := GET_PARAM('db_block_buffers') * bs;
    if bc = 0 then
    bc := GET_PARAM('db_cache_size')
    + GET_PARAM('db_keep_cache_size')
    + GET_PARAM('db_recycle_cache_size')
    + GET_PARAM('db_2k_cache_size')
    + GET_PARAM('db_4k_cache_size')
    + GET_PARAM('db_8k_cache_size')
    + GET_PARAM('db_16k_cache_size')
    + GET_PARAM('db_32k_cache_size');
    end if;
    sp := GET_PARAM('shared_pool_size');
    lb := GET_PARAM('log_buffer');
    twt := TOTAL_EVENT_TIME; -- total wait time for all non-idle events
    bspm := SGASTAT('total_shared_pool', bid);
    espm := SGASTAT('total_shared_pool', eid);
    bfrm := SGASTAT('free memory', bid);
    efrm := SGASTAT('free memory', eid);
    blog := GET_SYSSTAT('logons current', bid);
    elog := GET_SYSSTAT('logons current', eid);
    bocur := GET_SYSSTAT('opened cursors current', bid);
    eocur := GET_SYSSTAT('opened cursors current', eid);
    /* Do we want to report on cluster-specific statistics? Check
    in procedure variable "parallel".
    if parallel = 'YES' then
    dmsd := DLMDIF('messages sent directly');
    dmfc := DLMDIF('messages flow controlled');
    dmsi := DLMDIF('messages sent indirectly');
    dmrv := DLMDIF('messages received');
    dfcms := DLMDIF('flow control messages sent');
    dfcmr := DLMDIF('flow control messages received');
    dynal := DLMDIF('dynamically allocated enqueues');
    dynares := DLMDIF('dynamically allocated resources');
    pmrv := DLMDIF('gcs msgs received');
    pmpt := DLMDIF('gcs msgs process time(ms)');
    npmrv := DLMDIF('ges msgs received');
    npmpt := DLMDIF('ges msgs process time(ms)');
    scma := DLMDIF('gcs side channel msgs actual');
    scml := DLMDIF('gcs side channel msgs logical');
    pinc := DLMDIF('gcs immediate (null) converts');
    picrnc := DLMDIF('gcs immediate cr (null) converts');
    picc := DLMDIF('gcs immediate (compatible) converts');
    picrcc := DLMDIF('gcs immediate cr (compatible) converts');
    pbc := DLMDIF('gcs blocked converts');
    pbcrc := DLMDIF('gcs blocked cr converts');
    pcba := DLMDIF('gcs compatible basts');
    pccrba := DLMDIF('gcs compatible cr basts');
    pcrbpi := DLMDIF('gcs cr basts to PIs');
    dynapres := DLMDIF('dynamically allocated gcs resources');
    dynapshl := DLMDIF('dynamically allocated gcs shadows');
    prcma := DLMDIF('gcs recovery claim msgs actual');
    prcml := DLMDIF('gcs recovery claim msgs logical');
    pwrm := DLMDIF('gcs write request msgs');
    pfpim := DLMDIF('gcs flush pi msgs');
    pwnm := DLMDIF('gcs write notification msgs');
    dpms := SYSDIF('gcs messages sent');
    dnpms := SYSDIF('ges messages sent');
    glsg := SYSDIF('global lock sync gets');
    glag := SYSDIF('global lock async gets');
    glgt := SYSDIF('global lock get time');
    glsc := SYSDIF('global lock sync converts');
    glac := SYSDIF('global lock async converts');
    glct := SYSDIF('global lock convert time');
    glrl := SYSDIF('global lock releases');
    gcge := SYSDIF('global cache gets');
    gcgt := SYSDIF('global cache get time');
    gccv := SYSDIF('global cache converts');
    gcct := SYSDIF('global cache convert time');
    gccrrv := SYSDIF('global cache cr blocks received');
    gccrrt := SYSDIF('global cache cr block receive time');
    gccurv := SYSDIF('global cache current blocks received');
    gccurt := SYSDIF('global cache current block receive time');
    gccrsv := SYSDIF('global cache cr blocks served');
    gccrbt := SYSDIF('global cache cr block build time');
    gccrft := SYSDIF('global cache cr block flush time');
    gccrst := SYSDIF('global cache cr block send time');
    gccusv := SYSDIF('global cache current blocks served');
    gccupt := SYSDIF('global cache current block pin time');
    gccuft := SYSDIF('global cache current block flush time');
    gccust := SYSDIF('global cache current block send time');
    end if;
    /* Determine if we want to report on session-specific statistics.
    Check that the session is the same one for both snapshots.
    select session_id
    , serial#
    into l_b_session_id
    , l_b_serial#
    from stats$snapshot
    where snap_id = bid
    and dbid = db_ident
    and instance_number = inst_num;
    select session_id
    , serial#
    into l_e_session_id
    , l_e_serial#
    from stats$snapshot
    where snap_id = eid
    and dbid = db_ident
    and instance_number = inst_num;
    if ( (l_b_session_id = l_e_session_id)
    and (l_b_serial# = l_e_serial#)
    and (l_b_session_id != 0) ) then
    /* we have a valid comparison - it is the
    same session - get number of tx performed
    by this session */
    strn := SESDIF('user rollbacks') + SESDIF('user commits');
    if strn = 0 then
    /* No new transactions */
    strn := 1;
    end if;
    else
    /* No valid comparison can be made */
    strn :=1;
    end if;
    end STAT_CHANGES;
    function SNAP
    (i_snap_level in number default null
    ,i_session_id in number default null
    ,i_ucomment in varchar2 default null
    ,i_num_sql in number default null
    ,i_executions_th in number default null
    ,i_parse_calls_th in number default null
    ,i_disk_reads_th in number default null
    ,i_buffer_gets_th in number default null
    ,i_sharable_mem_th in number default null
    ,i_version_count_th in number default null
    ,i_all_init in varchar2 default null
    ,i_pin_statspack in varchar2 default null
    ,i_modify_parameter in varchar2 default 'FALSE'
    RETURN integer IS
    /* This function performs a snapshot of the v$ views into the
    stats$ tables, and returns the snapshot id.
    If parameters are passed, these are the values used, otherwise
    the values stored in the stats$statspack_parameter table are used.
    l_snap_id integer;
    l_snap_level number;
    l_session_id number;
    l_serial# number;
    l_ucomment varchar2(160);
    l_num_sql number;
    l_executions_th number;
    l_parse_calls_th number;
    l_disk_reads_th number;
    l_buffer_gets_th number;
    l_sharable_mem_th number;
    l_version_count_th number;
    l_all_init varchar2(5);
    l_pin_statspack varchar2(10);
    l_sql_stmt varchar2(3000);
    l_slarti varchar2(20);
    l_threshold number;
    l_total_sql number := 0;
    l_total_sql_mem number := 0;
    l_single_use_sql number := 0;
    l_single_use_sql_mem number := 0;
    l_text_subset varchar2(31);
    l_sharable_mem number;
    l_version_count number;
    l_sorts number;
    l_module varchar2(64);
    l_loaded_versions number;
    l_executions number;
    l_loads number;
    l_invalidations number;
    l_parse_calls number;
    l_disk_reads number;
    l_buffer_gets number;
    l_rows_processed number;
    l_address raw(8);
    l_hash_value number;
    l_version_count number;
    l_max_begin_time date;
    cursor GETSERIAL is
    select serial#
    from v$session
    where sid = l_session_id;
    PROCEDURE snap_sql IS
    begin
    /* Gather summary statistics */
    insert into stats$sql_statistics
    ( snap_id
    , dbid
    , instance_number
    , total_sql
    , total_sql_mem
    , single_use_sql
    , single_use_sql_mem
    select l_snap_id
    , p_dbid
    , p_instance_number
    , count(1)
    , sum(sharable_mem)
    , sum(decode(executions, 1, 1, 0))
    , sum(decode(executions, 1, sharable_mem, 0))
    from stats$v$sqlxs
    where is_obsolete = 'N';
    /* Gather SQL statements which exceed any threshold,
    excluding obsolete parent cursors
    insert into stats$sql_summary
    ( snap_id
    , dbid
    , instance_number
    , text_subset
    , sharable_mem
    , sorts
    , module
    , loaded_versions
    , executions
    , loads
    , invalidations
    , parse_calls
    , disk_reads
    , buffer_gets
    , rows_processed
    , command_type
    , address
    , hash_value
    , version_count
    , cpu_time
    , elapsed_time
    , outline_sid
    , outline_category
    select l_snap_id
    , p_dbid
    , p_instance_number
    , substr(sql_text,1,31)
    , sharable_mem
    , sorts
    , module
    , loaded_versions
    , executions
    , loads
    , invalidations
    , parse_calls
    , disk_reads
    , buffer_gets
    , rows_processed
    , command_type
    , address
    , hash_value
    , version_count
    , cpu_time
    , elapsed_time
    , outline_sid
    , outline_category
    from stats$v$sqlxs
    where is_obsolete = 'N'
    and ( buffer_gets > l_buffer_gets_th
    or disk_reads > l_disk_reads_th
    or parse_calls > l_parse_calls_th
    or executions > l_executions_th
    or sharable_mem > l_sharable_mem_th
    or version_count > l_version_count_th
    /* Insert the SQL Text for hash_values captured in the snapshot
    into stats$sqltext if it's not already there. Identify SQL which
    execeeded the threshold by querying stats$sql_summary for this
    snapid and database instance
    insert into stats$sqltext
    ( hash_value
    , text_subset
    , piece
    , sql_text
    , address
    , command_type
    , last_snap_id
    select st1.hash_value
    , ss.text_subset
    , st1.piece
    , st1.sql_text
    , st1.address
    , st1.command_type
    , ss.snap_id
    from v$sqltext st1
    , stats$sql_summary ss
    where ss.snap_id = l_snap_id
    and ss.dbid = p_dbid
    and ss.instance_number = p_instance_number
    and st1.hash_value = ss.hash_value
    and st1.address = ss.address
    and not exists (select 1
    from stats$sqltext st2
    where st2.hash_value = ss.hash_value
    and st2.text_subset = ss.text_subset
    IF l_snap_level >= 6 THEN
    /* Identify SQL which execeeded the threshold by querying
    stats$sql_summary for this snapid and database instance.
    Capture the plans which were used for the high-load SQL if
    don't already have this data.
    Omit capturing plan usage information for cursors which
    have a zero plan hash value.
    Currently this is captured in a level 6 (or greater)
    snapshot, however this may be integrated into level 5
    snapshot at a later date.
    hl - high load
    insert into stats$sql_plan_usage
    ( hash_value
    , text_subset
    , plan_hash_value
    , cost
    , snap_id
    , address
    , optimizer
    select hl.hash_value
    , hl.text_subset
    , hl.plan_hash_value
    , hl.cost
    , max(hl.snap_id)
    , max(hl.address)
    , max(hl.optimizer)
    from (select /*+ ordered use_nl(sq) index(sq) */
    ss.hash_value
    , ss.text_subset
    , sq.plan_hash_value
    , nvl(sq.optimizer_cost,-9) cost
    , ss.snap_id snap_id
    , ss.address
    , sq.optimizer_mode optimizer
    from stats$sql_summary ss
    , v$sql sq
    where ss.snap_id = l_snap_id
    and ss.dbid = p_dbid
    and ss.instance_number = p_instance_number
    and sq.hash_value = ss.hash_value
    and sq.address = ss.address
    and sq.plan_hash_value > 0
    ) hl
    where not exists (select /*+ no_unnest */
    from stats$sql_plan_usage spu
    where spu.hash_value = hl.hash_value
    and spu.text_subset = hl.text_subset
    and spu.plan_hash_value
    = hl.plan_hash_value
    and spu.cost = hl.cost
    group by hl.hash_value
    , hl.text_subset
    , hl.plan_hash_value
    , hl.cost
    , hl.optimizer;
    /* For all new hash_value, plan_hash_value, cost combinations
    just captured, get the optimizer plans, if we don't already
    have them. Note that the plan (and hence the plan hash value)
    comprises the access path and the join order (and not
    variable factors such as the cardinality).
    insert into stats$sql_plan
    ( plan_hash_value
    , id
    , operation
    , options
    , object_node
    , object#
    , object_owner
    , object_name
    , optimizer
    , parent_id
    , depth
    , position
    , cost
    , cardinality
    , bytes
    , other_tag
    , partition_start
    , partition_stop
    , partition_id
    , other
    , distribution
    , cpu_cost
    , io_cost
    , temp_space
    , snap_id
    select /*+ ordered use_nl(s) use_nl(sp.p) */
    new_plan.plan_hash_value
    , sp.id
    , max(sp.operation)
    , max(sp.options)
    , max(sp.object_node)
    , max(sp.object#)
    , max(sp.object_owner)
    , max(sp.object_name)
    , max(sp.optimizer)
    , max(sp.parent_id)
    , max(sp.depth)
    , max(sp.position)
    , max(sp.cost)
    , max(sp.cardinality)
    , max(sp.bytes)
    , max(sp.other_tag)
    , max(sp.partition_start)
    , max(sp.partition_stop)
    , max(sp.partition_id)
    , max(sp.other)
    , max(sp.distribution)
    , max(sp.cpu_cost)
    , max(sp.io_cost)
    , max(sp.temp_space)
    , max(new_plan.snap_id)
    from (select /*+ index(spu) */
    distinct
    spu.plan_hash_value
    , spu.hash_value
    , spu.address
    , spu.text_subset
    , spu.snap_id
    from stats$sql_plan_usage spu
    where spu.snap_id = l_snap_id
    and not exists (select /*+ nl_aj */ *
    from stats$sql_plan ssp
    where ssp.plan_hash_value
    = spu.plan_hash_value
    ) new_plan
    , v$sql s
    , v$sql_plan sp
    where sp.hash_value = new_plan.hash_value
    and sp.address = new_plan.address
    and s.hash_value = new_plan.hash_value
    and s.address = new_plan.address
    and s.hash_value = sp.hash_value
    and s.address = sp.address
    and s.child_number = sp.child_number
    group by
    new_plan.plan_hash_value
    , sp.id;
    END IF; /* snap level >=6 */
    END snap_sql;
    begin /* Function SNAP */
    /* Get instance parameter defaults from stats$statspack_parameter,
    or use supplied parameters.
    If all parameters are specified, use them, otherwise get values
    from the parameters not specified from stats$statspack_parameter.
    statspack.qam_statspack_parameter
    ( p_dbid
    , p_instance_number
    , i_snap_level, i_session_id, i_ucomment, i_num_sql
    , i_executions_th, i_parse_calls_th
    , i_disk_reads_th, i_buffer_gets_th, i_sharable_mem_th
    , i_version_count_th, i_all_init
    , i_pin_statspack
    , i_modify_parameter
    , l_snap_level, l_session_id, l_ucomment, l_num_sql
    , l_executions_th, l_parse_calls_th
    , l_disk_reads_th, l_buffer_gets_th, l_sharable_mem_th
    , l_version_count_th, l_all_init
    , l_pin_statspack);
    /* Generate a snapshot id */
    select stats$snapshot_id.nextval
    into l_snap_id
    from dual
    where rownum = 1;
    /* Determine the serial# of the session to maintain stats for,
    if this was requested.
    if l_session_id > 0 then
    if not GETSERIAL%ISOPEN then open GETSERIAL; end if;
    fetch GETSERIAL into l_serial#;
    if GETSERIAL%NOTFOUND then
    /* Session has already disappeared - don't gather
    statistics for this session in this snapshot */
    l_session_id := 0;
    l_serial# := 0;
    end if; close GETSERIAL;
    else
    l_serial# := 0;
    end if;
    /* The instance has been restarted since the last snapshot */
    if p_new_sga = 0
    then
    begin
    p_new_sga := 1;
    /* Get the instance startup time, and other characteristics */
    insert into stats$database_instance
    ( dbid
    , instance_number
    , startup_time
    , snap_id
    , parallel
    , version
    , db_name
    , instance_name
    , host_name
    select p_dbid
    , p_instance_number
    , p_startup_time
    , l_snap_id
    , p_parallel
    , p_version
    , p_name
    , p_instance_name
    , p_host_name
    from sys.dual;
    commit;
    end;
    end if; /* new SGA */
    /* Work out the max undo stat time, used for gathering undo stat data */
    select nvl(max(begin_time), to_date('01011900','DDMMYYYY'))
    into l_max_begin_time
    from stats$undostat
    where dbid = p_dbid
    and instance_number = p_instance_number;
    /* Save the snapshot characteristics */
    insert into stats$snapshot
    ( snap_id, dbid, instance_number
    , snap_time, startup_time
    , session_id, snap_level, ucomment
    , executions_th, parse_calls_th, disk_reads_th
    , buffer_gets_th, sharable_mem_th
    , version_count_th, serial#, all_init)
    values
    ( l_snap_id, p_dbid, p_instance_number
    , SYSDATE, p_startup_time
    , l_session_id, l_snap_level, l_ucomment
    , l_executions_th, l_parse_calls_th, l_disk_reads_th
    , l_buffer_gets_th, l_sharable_mem_th
    , l_version_count_th, l_serial#, l_all_init);
    /* Begin gathering statistics */
    insert into stats$filestatxs
    ( snap_id
    , dbid
    , instance_number
    , tsname
    , filename
    , phyrds
    , phywrts
    , singleblkrds
    , readtim
    , writetim
    , singleblkrdtim
    , phyblkrd
    , phyblkwrt
    , wait_count
    , time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , tsname
    , filename
    , phyrds
    , phywrts
    , singleblkrds
    , readtim
    , writetim
    , singleblkrdtim
    , phyblkrd
    , phyblkwrt
    , wait_count
    , time
    from stats$v$filestatxs;
    insert into stats$tempstatxs
    ( snap_id
    , dbid
    , instance_number
    , tsname
    , filename
    , phyrds
    , phywrts
    , singleblkrds
    , readtim
    , writetim
    , singleblkrdtim
    , phyblkrd
    , phyblkwrt
    , wait_count
    , time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , tsname
    , filename
    , phyrds
    , phywrts
    , singleblkrds
    , readtim
    , writetim
    , singleblkrdtim
    , phyblkrd
    , phyblkwrt
    , wait_count
    , time
    from stats$v$tempstatxs;
    insert into stats$librarycache
    ( snap_id
    , dbid
    , instance_number
    , namespace
    , gets
    , gethits
    , pins
    , pinhits
    , reloads
    , invalidations
    , dlm_lock_requests
    , dlm_pin_requests
    , dlm_pin_releases
    , dlm_invalidation_requests
    , dlm_invalidations
    select l_snap_id
    , p_dbid
    , p_instance_number
    , namespace
    , gets
    , gethits
    , pins
    , pinhits
    , reloads
    , invalidations
    , dlm_lock_requests
    , dlm_pin_requests
    , dlm_pin_releases
    , dlm_invalidation_requests
    , dlm_invalidations
    from v$librarycache;
    insert into stats$buffer_pool_statistics
    ( snap_id
    , dbid
    , instance_number
    , id
    , name
    , block_size
    , set_msize
    , cnum_repl
    , cnum_write
    , cnum_set
    , buf_got
    , sum_write
    , sum_scan
    , free_buffer_wait
    , write_complete_wait
    , buffer_busy_wait
    , free_buffer_inspected
    , dirty_buffers_inspected
    , db_block_change
    , db_block_gets
    , consistent_gets
    , physical_reads
    , physical_writes
    select l_snap_id
    , p_dbid
    , p_instance_number
    , id
    , name
    , block_size
    , set_msize
    , cnum_repl
    , cnum_write
    , cnum_set
    , buf_got
    , sum_write
    , sum_scan
    , free_buffer_wait
    , write_complete_wait
    , buffer_busy_wait
    , free_buffer_inspected
    , dirty_buffers_inspected
    , db_block_change
    , db_block_gets
    , consistent_gets
    , physical_reads
    , physical_writes
    from v$buffer_pool_statistics;
    insert into stats$rollstat
    ( snap_id
    , dbid
    , instance_number
    , usn
    , extents
    , rssize
    , writes
    , xacts
    , gets
    , waits
    , optsize
    , hwmsize
    , shrinks
    , wraps
    , extends
    , aveshrink
    , aveactive
    select l_snap_id
    , p_dbid
    , p_instance_number
    , usn
    , extents
    , rssize
    , writes
    , xacts
    , gets
    , waits
    , optsize
    , hwmsize
    , shrinks
    , wraps
    , extends
    , aveshrink
    , aveactive
    from v$rollstat;
    insert into stats$rowcache_summary
    ( snap_id
    , dbid
    , instance_number
    , parameter
    , total_usage
    , usage
    , gets
    , getmisses
    , scans
    , scanmisses
    , scancompletes
    , modifications
    , flushes
    , dlm_requests
    , dlm_conflicts
    , dlm_releases
    select l_snap_id
    , p_dbid
    , p_instance_number
    , parameter
    , sum("COUNT")
    , sum(usage)
    , sum(gets)
    , sum(getmisses)
    , sum(scans)
    , sum(scanmisses)
    , sum(scancompletes)
    , sum(modifications)
    , sum(flushes)
    , sum(dlm_requests)
    , sum(dlm_conflicts)
    , sum(dlm_releases)
    from v$rowcache
    group by l_snap_id, p_dbid, p_instance_number, parameter;
    /* Collect parameters every snapshot, to cater for dynamic
    parameters changable while instance is running
    if l_all_init = 'FALSE' then
    insert into stats$parameter
    ( snap_id
    , dbid
    , instance_number
    , name
    , value
    , isdefault
    , ismodified
    select l_snap_id
    , p_dbid
    , p_instance_number
    , name
    , value
    , isdefault
    , ismodified
    from v$system_parameter;
    else
    insert into stats$parameter
    ( snap_id
    , dbid
    , instance_number
    , name
    , value
    , isdefault
    , ismodified
    select l_snap_id
    , p_dbid
    , p_instance_number
    , i.ksppinm
    , sv.ksppstvl
    , sv.ksppstdf
    , decode(bitand(sv.ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE')
    from stats$x$ksppi i
    , stats$x$ksppsv sv
    where i.indx = sv.indx;
    end if;
    /* To cater for variable size SGA - insert on each snapshot */
    insert into stats$sga
    ( snap_id
    , dbid
    , instance_number
    , name
    , value
    select l_snap_id
    , p_dbid
    , p_instance_number
    , name
    , value
    from v$sga;
    /* Get current allocation of memory in the SGA */
    insert into stats$sgastat
    ( snap_id
    , dbid
    , instance_number
    , pool
    , name
    , bytes
    select l_snap_id
    , p_dbid
    , p_instance_number
    , pool
    , name
    , bytes
    from v$sgastat;
    insert into stats$system_event
    ( snap_id
    , dbid
    , instance_number
    , event
    , total_waits
    , total_timeouts
    , time_waited_micro
    select l_snap_id
    , p_dbid
    , p_instance_number
    , event
    , total_waits
    , total_timeouts
    , time_waited_micro
    from v$system_event;
    insert into stats$bg_event_summary
    ( snap_id
    , dbid
    , instance_number
    , event
    , total_waits
    , total_timeouts
    , time_waited_micro
    select l_snap_id
    , p_dbid
    , p_instance_number
    , e.event
    , sum(e.total_waits)
    , sum(e.total_timeouts)
    , sum(e.time_waited_micro)
    from v$session_event e
    where e.sid in (select s.sid from v$session s where s.type = 'BACKGROUND')
    group by l_snap_id, p_dbid, p_instance_number, e.event;
    insert into stats$sysstat
    ( snap_id
    , dbid
    , instance_number
    , statistic#
    , name
    , value
    select l_snap_id
    , p_dbid
    , p_instance_number
    , statistic#
    , name
    , value
    from v$sysstat;
    insert into stats$waitstat
    ( snap_id
    , dbid
    , instance_number
    , class
    , wait_count
    , time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , class
    , "COUNT"
    , time
    from v$waitstat;
    insert into stats$enqueue_stat
    ( snap_id
    , dbid
    , instance_number
    , eq_type
    , total_req#
    , total_wait#
    , succ_req#
    , failed_req#
    , cum_wait_time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , eq_type
    , total_req#
    , total_wait#
    , succ_req#
    , failed_req#
    , cum_wait_time
    from v$enqueue_stat
    where total_req# != 0;
    insert into stats$latch
    ( snap_id
    , dbid
    , instance_number
    , name
    , latch#
    , level#
    , gets
    , misses
    , sleeps
    , immediate_gets
    , immediate_misses
    , spin_gets
    , sleep1
    , sleep2
    , sleep3
    , sleep4
    , wait_time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , name
    , latch#
    , level#
    , gets
    , misses
    , sleeps
    , immediate_gets
    , immediate_misses
    , spin_gets
    , sleep1
    , sleep2
    , sleep3
    , sleep4
    , wait_time
    from v$latch;
    insert into stats$latch_misses_summary
    ( snap_id
    , dbid
    , instance_number
    , parent_name
    , where_in_code
    , nwfail_count
    , sleep_count
    , wtr_slp_count
    select l_snap_id
    , p_dbid
    , p_instance_number
    , parent_name
    , "WHERE"
    , sum(nwfail_count)
    , sum(sleep_count)
    , sum(wtr_slp_count)
    from v$latch_misses
    where sleep_count > 0
    group by l_snap_id, p_dbid, p_instance_number
    , parent_name, "WHERE";
    insert into stats$resource_limit
    ( snap_id
    , dbid
    , instance_number
    , resource_name
    , current_utilization
    , max_utilization
    , initial_allocation
    , limit_value
    select l_snap_id
    , p_dbid
    , p_instance_number
    , resource_name
    , current_utilization
    , max_utilization
    , initial_allocation
    , limit_value
    from v$resource_limit
    where limit_value != ' UNLIMITED'
    and max_utilization > 0;
    insert into stats$undostat
    ( begin_time
    , end_time
    , dbid
    , instance_number
    , snap_id
    , undotsn
    , undoblks
    , txncount
    , maxquerylen
    , maxconcurrency
    , unxpstealcnt
    , unxpblkrelcnt
    , unxpblkreucnt
    , expstealcnt
    , expblkrelcnt
    , expblkreucnt
    , ssolderrcnt
    , nospaceerrcnt
    select begin_time
    , end_time
    , p_dbid
    , p_instance_number
    , l_snap_id
    , undotsn
    , undoblks
    , txncount
    , maxquerylen
    , maxconcurrency
    , unxpstealcnt
    , unxpblkrelcnt
    , unxpblkreucnt
    , expstealcnt
    , expblkrelcnt
    , expblkreucnt
    , ssolderrcnt
    , nospaceerrcnt
    from v$undostat
    where begin_time > l_max_begin_time
    and begin_time + (1/(24*6)) <= end_time;
    insert into stats$db_cache_advice
    ( snap_id
    , dbid
    , instance_number
    , id
    , name
    , block_size
    , buffers_for_estimate
    , advice_status
    , size_for_estimate
    , estd_physical_read_factor
    , estd_physical_reads
    select l_snap_id
    , p_dbid
    , p_instance_number
    , id
    , name
    , block_size
    , buffers_for_estimate
    , advice_status
    , size_for_estimate
    , estd_physical_read_factor
    , estd_physical_reads
    from v$db_cache_advice
    where advice_status = 'ON';
    insert into stats$pgastat
    ( snap_id
    , dbid
    , instance_number
    , name
    , value
    select l_snap_id
    , p_dbid
    , p_instance_number
    , name
    , value
    from v$pgastat;
    insert into stats$instance_recovery
    ( snap_id
    , dbid
    , instance_number
    , recovery_estimated_ios
    , actual_redo_blks
    , target_redo_blks
    , log_file_size_redo_blks
    , log_chkpt_timeout_redo_blks
    , log_chkpt_interval_redo_blks
    , fast_start_io_target_redo_blks
    , target_mttr
    , estimated_mttr
    , ckpt_block_writes
    select l_snap_id
    , p_dbid
    , p_instance_number
    , recovery_estimated_ios
    , actual_redo_blks
    , target_redo_blks
    , log_file_size_redo_blks
    , log_chkpt_timeout_redo_blks
    , log_chkpt_interval_redo_blks
    , fast_start_io_target_redo_blks
    , target_mttr
    , estimated_mttr
    , ckpt_block_writes
    from v$instance_recovery;
    if p_parallel = 'YES' then
    insert into stats$dlm_misc
    ( snap_id
    , dbid
    , instance_number
    , statistic#
    , name
    , value
    select l_snap_id
    , p_dbid
    , p_instance_number
    , statistic#
    , name
    , value
    from v$dlm_misc;
    end if; /* parallel */
    /* Begin gathering Extended Statistics */
    IF l_snap_level >= 5 THEN
    snap_sql;
    END IF; /* snap level >=5 */
    IF l_snap_level >= 10 THEN
    insert into stats$latch_children
    ( snap_id
    , dbid
    , instance_number
    , latch#
    , child#
    , gets
    , misses
    , sleeps
    , immediate_gets
    , immediate_misses
    , spin_gets
    , sleep1
    , sleep2
    , sleep3
    , sleep4
    , wait_time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , latch#
    , child#
    , gets
    , misses
    , sleeps
    , immediate_gets
    , immediate_misses
    , spin_gets
    , sleep1
    , sleep2
    , sleep3
    , sleep4
    , wait_time
    from v$latch_children;
    insert into stats$latch_parent
    ( snap_id
    , dbid
    , instance_number
    , latch#
    , level#
    , gets
    , misses
    , sleeps
    , immediate_gets
    , immediate_misses
    , spin_gets
    , sleep1
    , sleep2
    , sleep3
    , sleep4
    , wait_time
    select l_snap_id
    , p_dbid
    , p_instance_number
    , latch#
    , level#
    , gets
    , misses
    , sleeps
    , immediate_gets
    , immediate_misses
    , spin_gets
    , sleep1
    , sleep2
    , sleep3
    , sleep4
    , wait_time
    from v$latch_parent;
    END IF; /* snap level >=10 */
    /* Record level session-granular statistics if a specific session
    has been requested
    if l_session_id > 0
    then
    insert into stats$sesstat
    ( snap_id
    , dbid
    , instance_number
    , statistic#
    , value
    select l_snap_id
    , p_dbid
    , p_instance_number
    , statistic#
    , value
    from v$sesstat
    where sid = l_session_id;
    insert into stats$session_event
    ( snap_id
    , dbid
    , instance_number
    , event
    , total_waits
    , total_timeouts
    , time_waited_micro
    , max_wait
    select l_snap_id
    , p_dbid
    , p_instance_number
    , event
    , total_waits
    , total_timeouts
    , time_waited_micro
    , max_wait
    from v$session_event
    where sid = l_session_id;
    end if;
    commit work;
    RETURN l_snap_id;
    end SNAP; /* Function SNAP */
    begin /* STATSPACK body */
    /* Query the database id, instance_number, database name, instance
    name and startup time for the instance we are working on
    /* Get information about the current instance */
    open get_instance;
    fetch get_instance into
    p_instance_number, p_instance_name
    , p_startup_time, p_parallel, p_version
    , p_host_name;
    close get_instance;
    /* Select the database info for the db connected to */
    open get_db;
    fetch get_db into p_dbid, p_name;
    close get_db;
    /* Keep the package
    sys.dbms_shared_pool.keep('PERFSTAT.STATSPACK', 'P');
    /* Determine if the instance has been restarted since the previous snapshot
    begin
    select 1
    into p_new_sga
    from stats$database_instance
    where startup_time = p_startup_time
    and dbid = p_dbid
    and instance_number = p_instance_number;
    exception
    when NO_DATA_FOUND then
    p_new_sga := 0;
    end;
    end STATSPACK;
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY STATSPACK:
    LINE/COL ERROR
    2045/3 PLS-00201: identifier 'SYS.DBMS_SHARED_POOL' must be declared
    2045/3 PL/SQL: Statement ignored

    When i compiled the package, it compiled with following error.
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY STATSPACK:
    LINE/COL ERROR
    2045/3 PLS-00201: identifier 'SYS.DBMS_SHARED_POOL' must be declared
    2045/3 PL/SQL: Statement ignored
    SQL>

  • 9I STATSPACK PACKAGE를 이용하여 생성된 성능보고서 분석 예제

    제품 : ORACLE SERVER
    작성날짜 : 2005-01-07
    9I STATSPACK PACKAGE를 이용하여 생성된 성능보고서 분석 예제
    ==========================================
    PURPOSE
    이 문서는 9i 데이타베이스 운영 중 전반적인 System performance
    저하를 경험할 경우 StatsPack Package를 이용하여 성능관련 문제
    분석에 활용하는 방법을 예제를 통해 알아보기로 한다.
    Explanation
    <Bulletin:17118>에는 statspack.snap 프로시져를 수행하여 snapshot을
    생성하는 데 있어 통계정보 수집 방법에 대하여 자세히 소개되어 있다.
    <Bulletin:17119>에는 spreport.sql 수행을 통한 STATSPACK 성능 보고서
    생성 방법과 생성되는 report의 내용을 요약적으로 볼 수 있다.
    이 문서는 STATSPACK utility에 의해 생성되는 이 output(성능보고서)을
    이해하고 진단하는 데 도움을 줄 만한 내용을 알아본다.
    데이타베이스 performance tuning은 아주 광범위한 분야이므로,
    아 자료는 몇 가지 특정 tuning point에 대해서만 촛점을 맞추어 알아본다.
    1. 9i 에서 statspack 수행 시 Summary Information
    STATSPACK report for
    DB Name DB Id Instance Inst Num Release Cluster Host
    ETSPRD7 1415901831 etsprd7a 1 9.2.0.5.0 YES tsonode1
    Snap Id Snap Time Sessions Curs/Sess Comment
    Begin Snap: 71 11-Jun-04 10:02:41 ####### .0
    End Snap: 73 11-Jun-04 12:09:00 ####### .0
    Elapsed: 126.32 (mins)
    ==> 이전의 OPS 항목은 Real Applications Cluster(RAC) 라고 하는 새로운
    용어를 나타내기 위해 Cluster로 대체되었다.
    그리고, Cursors/Session 과 Comment라고 하는 column이 추가되었다.
    2. Oracle 9i Instance Workload Information
    모든 statspack report는 instance efficiency를 결정하는 데 도움이 될
    만한 인스턴스 metric들과 인스턴스의 workload profile을 보여주는 것으로
    시작한다.
    Oracle 9i에서 Std Block size는 인스턴스의 primary block size를 나타낸다.
    1) Instance cache information:
    Cache Sizes (end)
    ~~~~~~~~~~~~~~~~~
    Buffer Cache: 704M Std Block Size: 8K
    Shared Pool Size: 256M Log Buffer: 1,024K
    2) Load profile Information:
    Load profile Information은 Oracle 8i와 9i가 모두 동일하다.
    Load Profile
    ~~~~~~~~~~~~
    Per Second Per Transaction
    Redo size: 351,530.67 7,007.37
    Logical reads: 5,449.81 108.64
    Block changes: 1,042.0 8 20.77
    Physical reads: 37.71 0.75
    Physical writes: 134.68 2.68
    User calls: 1,254.72 25.01
    Parses: 4.92 0.10
    Hard parses: 0.02 0.00
    Sorts: 15.73 0.31
    Logons: -0.01 0.00
    Executes: 473.73 9.44
    Transactions: 50.17
    % Blocks changed per Read: 19.12 Recursive Call %: 4.71
    Rollback per transaction %: 2.24 Rows per Sort: 20.91
    각 항목들의 의미는 다음과 같다.
    Redo size: This is the amount of redo generated during this report.
    Logical Reads: This is calculated as Consistent Gets + DB Block Gets = Logical Reads
    Block changes: The number of blocks modified during the sample interval
    Physical Reads: The number of requests for a block that caused a physical I/O.
    Physical Writes: The number of physical writes issued.
    User Calls: The number of queries generated
    Parses: Total of all parses: both hard and soft
    Hard Parses: Those parses requiring a completely new parse of the
    SQL statement. These consume both latches and shared pool area.
    Soft Parses: Not listed but derived by subtracting the hard parses
    from parses. A soft parse reuses a previous hard parse
    and hence consumes far fewer resources.
    Sorts, Logons, Executes and Transactions are all self explanatory
    3) Instance Efficiency Ratios:
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Buffer Nowait %: 99.99 Redo NoWait %: 100.00
    Buffer Hit %: -45.57 In-memory Sort %: 97.55
    Library Hit %: 99.89 Soft Parse %: 99.72
    Execute to Parse %: -1.75 Latch Hit %: 99.11
    Parse CPU to Parse Elapsd %: 52.66 % Non-Parse CPU: 99.99
    Shared Pool Statistics Begin End
    Memory Usage %: 42.07 43.53
    % SQL with executions>1: 73.79 75.08
    % Memory for SQL w/exec>1: 76.93 77.64
    Example
    1. Parse가 너무 빈번하여 성능에 영향을 주는 예제
    예제1. TARGET 이 100% 인데 다른 항목들은 좋은 편이지만, PARSE 관련
    비율들만 낮은 경향을 보임.
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Buffer Nowait %: 99.93 Redo NoWait %: 99.99
    Buffer Hit %: 97.97 In-memory Sort %: 100.00
    Library Hit %: 93.58 Soft Parse %: 85.59
    Execute to Parse %: 10.21 Latch Hit %: 99.48
    Parse CPU to Parse Elapsd %: 40.07 % Non-Parse CPU: 90.54
    예제2. 한번 PARSE해서 한번만 수행한 SQL이 전체 SQL 의 40% 나 차지하는 경우
    이러한 경우 권장사항은 한번 PARSE하여 여러번 수행하는 것이다.
    Shared Pool Statistics Begin End
    Memory Usage %: 94.13 94.95
    % SQL with executions>1: 40.43 36.56
    % Memory for SQL w/exec>1: 31.67 26.27
    예제3. 다음 정보는 빈번하게 수행되면서, 수행할 때마다 PARSE하는 SQL들이다.
    SQL ordered by Parse Calls for DB:
    % Total
    Parse Calls Executions Parses Hash Value
    191,537 191,538 5.31 2386297721
    Module: OCS00000.exe
    SELECT DOCTNO, CLINIC, DOCTNAME FROM OCSUSER.OCSDOCTOR
    WHERE ROWNUM = 1 -- AND DOCTNO > ' ' --2004/03/02 LEEJUNGHY
    UN -- AND DOCTNO IN (P_DOCTNO,SUBSTR(P_DOCTNO,-5)); A
    ND DOCTNO = TRIM(TO_CHAR(SUBSTR(:b1,GREATEST(LENGTH(:b1)*(-1),-5
    )),'00000'))
    102,871 102,871 2.85 102761273
    Module: OCS00000.exe
    SELECT KORNAME FROM EPMUSER.EPMMASTER WHERE EMPNO IN (:
    b1,SUBSTR(:b1,-5))
    92,454 92,454 2.56 231443659
    Module: NIN00000.exe
    SELECT USERID FROM APMUSER.APMSESSIONID WHERE INSTANC
    ENO = USERENV('INSTANCE') AND SESSIONID = USERENV('S
    ESSIONID')
    예제4. SQL을 shared pool에 할당하는 관련 LATCH 들의 MISS가 보이는 경우
    Latch Activity for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    ->"Get Requests", "Pct Get Miss" and "Avg Slps/Miss" are statistics for
    willing-to-wait latch get requests.
    ->"NoWait Requests", "Pct NoWait Miss" are for no-wait latch get requests.
    ->"Pct Misses" for both should be very close to 0.0
    Pct Avg Wait Pct
    Get Get Slps Time NoWait NoWait
    Latch Requests Miss /Miss (s) Requests Miss
    library cache 60,564,808 1.9 0.2 1318 1,431,661 9.8
    library cache pin 28,629,340 0.1 0.1 9 0
    library cache pin alloca 19,120,395 0.1 0.1 5 0
    shared pool 63,075,980 4.0 0.1 578
    예제5. V$librarycache 뷰의 정보 중 SQL AREA의 MISS가 있는 경우
    Library Cache Activity for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    ->"Pct Misses" should be very low
    Get Pct Pin Pct Invali-
    Namespace Requests Miss Requests Miss Reloads dations
    SQL AREA 2,766,961 15.6 11,370,919 9.1 87,750 6
    TABLE/PROCEDURE 1,166,084 0.1 3,925,826 0.1 2,081 0
    BODY 45,742 0.0 45,742 0.0 0 0
    TRIGGER 808,617 0.0 808,624 0.0 30 0
    CLUSTER 717 0.0 523 0.0 0 0
    예제6. SHARED POOL USAGE 를 볼 때 2G 중 SQL AREA + LIBRARY CACHE가 대부분 차지
    SGA Memory Summary for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    SGA regions Size in Bytes
    Database Buffers 1,509,949,440
    Fixed Size 459,920
    Redo Buffers 679,936
    Variable Size 2,164,260,864
    sum 3,675,350,160
    shared_pool_size = 2013265920
    SGA breakdown difference for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    Pool Name Begin value End value % Diff
    shared library cache 465,599,756 467,728,476 0.46
    shared sql area 1,283,939,172 1,300,770,180 1.31
    shared miscellaneous 150,304,904 151,676,316 0.91
    shared free memory 125,065,548 107,550,900 14.00
    너무 빈번한 Parse를 줄이기 위한 권장사항
    - Literal SQL보다는 BIND VARIABLE 사용 권장
    - SOFT PARSE가 85%나 차지하므로 Session_cached_cursors 파라미터 설정 권장
    ( 가령 100 --> 200 )
    이 파라미터에 지정한 갯수는 한 session 동안 open된 상태로 cache에
    유지할 수 있는 cursor의 갯수이다.
    <참고> CURSOR 는 한번 오픈된 다음 여러번 execution 될 수 있다.
    예를 들어 V$SQL 뷰에서 한 SQL 이 몇번 execute 되었는지는
    v$sqlarea.executions 로 확인 가능하다.
    <Note:30804.1> 참조
    2. SQL ACCESS PATH(SQL 수행 패턴)와 I/O에 문제가 있어 성능에 영향을 주는 예제
    SQL 수행 시 full table scan보다 INDEX scan이 항상 더 빠른 것은 아니다.
    예제1. 전체 WAIT TIME 의 대부분(60~70%)이 DB FILE SEQUENTIAL READ,
    즉 one block read (주로 인덱스 사용)일 때이다.
    Top 5 Timed Events
    ~~~~~~~~~~~~~~~~~~ % Total
    Event Waits Time (s) Ela Time
    db file sequential read 3,682,330 87,681 59.32
    CPU time 31,297 21.17
    global cache cr request 4,254,569 11,086 7.50
    enqueue 43,040 3,211 2.17
    latch free 505,497 2,068 1.40
    예제2. Tablespace IO Stats for DB , File IO Stats for DB 등의 DISK IO
    통계정보를 보면 AV Read 속도가 권장이 20ms 이하이나 대부분이
    20ms 이상이고 30ms 인 경우
    Tablespace IO Stats for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    ->ordered by IOs (Reads + Writes) desc
    Tablespace Av Av Av Av Buffer Av Buf
    Reads Reads/s Rd(ms) Blks/Rd Writes Writes/s Waits Wt(ms)
    OCS_DATA 1,320,724 174 25.0 1.0 34,046 4 90,263 22.5
    AMP_DATA 589,915 78 25.6 1.1 6,487 1 4,994 28.9
    OCS_IDX 282,622 37 26.9 1.0 54,707 7 7,813 25.6
    CP_DATA 204,100 27 18.2 1.1 3,297 0 1,594 17.3
    AMP_IDX 174,413 23 26.4 1.0 16,853 2 5,833 28.9
    File IO Stats for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    ->ordered by Tablespace, File
    Tablespace Filename
    Av Av Av Av Buffer Av Buf
    Reads Reads/s Rd(ms) Blks/Rd Writes Writes/s Waits Wt(ms)
    AMP_DATA /dev/vx/rdsk/dongadg/daumc_amp_data_30720m
    444,094 59 26.0 1.1 3,311 0 3,716 29.9
    /dev/vx/rdsk/dongadg/daumc_rdat0301_10240m
    74,911 10 24.5 1.1 1,124 0 685 26.5
    /dev/vx/rdsk/dongadg/daumc_rdat0303_10240m
    70,910 9 24.3 1.1 2,052 0 593 25.8
    AMP_IDX /dev/vx/rdsk/dongadg/daumc_amp_idx_30720m
    174,413 23 26.4 1.0 16,853 2 5,833 28.9
    AMS_DATA /dev/vx/rdsk/dongadg/daumc_ams_data_4096m
    11 0 26.4 1.0 0 0 0
    위의 Disk I/O Tuning point를 근거로 튜닝 필요한 SQL 찾기
    예제3. SQL ordered by Gets for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    -> End Buffer Gets Threshold: 10000
    -> Note that resources reported for PL/SQL includes the resources used by
    all SQL statements called within the PL/SQL code. As individual SQL
    statements are also reported, it is possible and valid for the summed
    total % to exceed 100
    CPU Elapsd
    Buffer Gets Executions Gets per Exec %Total Time (s) Time (s) Hash Value
    5,029,778 20 251,488.9 2.5 62.87 106.97 1740340670
    Module: NMS00000.exe
    SELECT ns.getdate, ns.gettime, ns.sid, ns.idno, ns.name
    , ns.ward, ns.sex, ns.age, ns.sampcd, we.workcd, MIN(nr
    .testcd) testcd, MIN(nr.testno) testno, MIN(nr.result)
    result, MIN(nr.ROWID) nrROWID, sm.sampnm FROM nmusr.nmsample
    ns, nmusr.nmresult nr, nmusr.nmworkenv we, nmusr.xnmsa
    3,200,846 1,903 1,682.0 1.6 99.29 184.85 2896635021
    Module: OCS00000.exe
    SELECT upslipcode FROM ocsuser.ocsslip WHERE slipcode
    = 'PH11' START WITH slipcode = 'CLIN' CONNECT BY PRIOR slipcod
    e = upslipcode
    예제4. SQL ordered by Reads for DB: DAUMC Instance: DAUMC1 Snaps: 71 -73
    -> End Disk Reads Threshold: 1000
    CPU Elapsd
    Physical Reads Executions Reads per Exec %Total Time (s) Time (s) Hash Value
    39,256 113 347.4 0.9 33.07 226.06 639735119
    Module: AMI00000.exe
    begin AMPUSER.MAKEADMORDER(:V00001,:V00002,:V00003,:V00004,:V000
    05,:V00006); end;
    38,671 113 342.2 0.9 15.23 167.19 3348585719
    Module: AMI00000.exe
    DELETE FROM AMPUSER.AMPTEMPORDER WHERE ( IDNO = :b4 AND MEDDAT
    E = :b3 AND TYPECODE = :b2) OR TERMID = :b1
    31,358 1 31,358.0 0.8 6.46 88.00 3852126455
    Module: Golden32.exe
    select count(*) FROM cpusr.cpslipuse su -- WHERE su.slipcd = '2
    1' -- AND su.partcd = 'MP' -- AND su.finalflag = 0 -- AND
    SUBSTR(su.labno,1,1) = '1' -- AND LENGTH(su.labno) = 6 --308
    Reference Documents
    <Note:228913.1> Systemwide Tuning using STATSPACK Reports

  • Problem with statspack package in oracle 9i

    Hi
    we are using oracle 9i(9.2.0.1.0).Installed stats pack package ,its created perfstat user(( created tablespace called perfstat and size 500m ) but tables not created. Afetr that
    sql>conn perfstat/perfstat@x;
    sql>select * from tab;
    no rows selected
    I had run the below scripts
    @d:\oracle\ora92\rdbms\admin\spcusr.sql
    @d:\oracle\ora92\rdbms\admin\spctab.sql
    @d:\oracle\ora92\rdbms\admin\spcreate.sql
    Thanks inadvance
    MM

    Note that the spcreate.sql script will run all the other scripts necessary to create the perfstat user and its objects.
    All you had to do was run the spcreate.sql script to all the steps necessary.

  • Running statspack report remotely from a client?

    Hi!
    To get a statspack report I run @spreport.sql from an SQL*Plus session on the database server.
    Having to go to the DB server for that sometimes is a chore and I would prefer to get a report from any client, or even from within SQL Developer.
    Is there an easy way to achive this or is there a tool for that?
    Obviously, the spreport.sql might differ from Oracle DB version to version, so I would either need to have a series of these reports scripts on the client and the select the right one or I would need to have some mechanisum (stored proc?) that gets to rdbms/admin on the server, executed the spreport.sql script there, read the output and return that from to the client.
    Is there an easier way or anyone knows of a package that will do that?
    Thanks,
    Marcus

    Marcus,
    I don't think that I did get your question. Sorry but do you mean to say that you want a report from the client terminal , running locally over teh client only? That's what I got from this line,
    Having to go to the DB server for that sometimes is a chore and I would prefer to get a report from any client, or even from within SQL Developer. Or do you want the report to be available from the server side to the client's local machine?
    If you want the report to be given to you on the client side only, I am not sure that there is any way possibly there. What's the issue in fetching the report from the server though ? If one can connect to db as a valid db and o/s user, he can fetch the data as well. But its just a thought. I don't use any of the tools much so I guess, I shall just join you and see what others have to say about it.
    Aman....

  • Error in creating perfstat user for statspack

    Hi Friends,
    DB: 11.2.0.2, SE and 64 bit
    OS: RHEL 5.7
    My DB is on SE and hence i cannot use the diagonistic pack so when i am trying to use Statspack for the same, i am facing the following error when i am trying to create Perfstat user.
    SQL> @?/rdbms/admin/spcreate
    Choose the PERFSTAT user's password
    Not specifying a password will result in the installation FAILING
    Enter value for perfstat_password: perfstat
    perfstat
    Choose the Default tablespace for the PERFSTAT user
    Below is the list of online tablespaces in this database which can
    store user data. Specifying the SYSTEM tablespace for the user's
    default tablespace will result in the installation FAILING, as
    using SYSTEM for performance data is not supported.
    Choose the PERFSTAT users's default tablespace. This is the tablespace
    in which the STATSPACK tables and indexes will be created.
    TABLESPACE_NAME CONTENTS STATSPACK DEFAULT TABLESPACE
    INDUS_SML_DATA PERMANENT
    INDUS_SML_INDEX PERMANENT
    PERFSTAT PERMANENT
    SYSAUX PERMANENT *
    USERS PERMANENT
    Pressing <return> will result in STATSPACK's recommended default
    tablespace (identified by *) being used.
    Enter value for default_tablespace: PERFSTAT
    Using tablespace PERFSTAT as PERFSTAT default tablespace.
    Choose the Temporary tablespace for the PERFSTAT user
    Below is the list of online tablespaces in this database which can
    store temporary data (e.g. for sort workareas). Specifying the SYSTEM
    tablespace for the user's temporary tablespace will result in the
    installation FAILING, as using SYSTEM for workareas is not supported.
    Choose the PERFSTAT user's Temporary tablespace.
    TABLESPACE_NAME CONTENTS DB DEFAULT TEMP TABLESPACE
    TEMP TEMPORARY *
    Pressing <return> will result in the database's default Temporary
    tablespace (identified by *) being used.
    Enter value for temporary_tablespace: TEMP
    Using tablespace TEMP as PERFSTAT temporary tablespace.
    ... Creating PERFSTAT user
    ... Installing required packages
    ... Creating views
    ... Granting privileges
    NOTE:
    SPCUSR complete. Please check spcusr.lis for any errors.
    SQL>
    SQL> --
    SQL> -- Build the tables and synonyms
    SQL> connect perfstat/&&perfstat_password
    Connected.
    SQL> @@spctab
    SQL> Rem
    SQL> Rem $Header: rdbms/admin/spctab.sql /st_rdbms_11.2.0/1 2010/08/13 10:06:01 kchou Exp $
    SQL> Rem
    SQL> Rem spctab.sql
    SQL> Rem
    SQL> Rem Copyright (c) 1999, 2010, Oracle and/or its affiliates.
    SQL> Rem All rights reserved.
    SQL> Rem
    SQL> Rem NAME
    SQL> Rem spctab.sql
    SQL> Rem
    SQL> Rem DESCRIPTION
    SQL> Rem SQL*PLUS command file to create tables to hold
    SQL> Rem start and end "snapshot" statistical information
    SQL> Rem
    SQL> Rem NOTES
    SQL> Rem Should be run as STATSPACK user, PERFSTAT
    SQL> Rem
    SQL> Rem MODIFIED (MM/DD/YY)
    SQL> Rem kchou 08/11/10 - Bug#9800868 - Add Missing Idle Events for
    SQL> Rem 11.2.0.2for Statspack & Standby Statspack
    SQL> Rem kchou 08/11/10 - Bug#9800868 - Add missing idle events to 11.2.0.2
    SQL> Rem cgervasi 05/13/09 - add idle event: cell worker idle
    SQL> Rem cgervasi 04/02/09 - bug8395154: missing idle events
    SQL> Rem rhlee 02/22/08 -
    Rem cdgreen 03/14/07 - 11 F2SQL> Rem shsong 06/14/07 - Add idle events
    SQL> Rem cdgreen 02/28/07 - 5908354
    SQL> Rem cdgreen 04/26/06 - 11 F1
    SQL> Rem cdgreen 06/26/06 - Increase column length
    SQL> Rem cdgreen 05/10/06 - 5215982
    SQL> Rem cdgreen 05/24/05 - 4246955
    SQL> Rem cdgreen 04/18/05 - 4228432
    SQL> Rem cdgreen 03/08/05 - 10gR2 misc
    SQL> Rem vbarrier 02/18/05 - 4081984
    SQL> Rem cdgreen 10/29/04 - 10gR2_sqlstats
    SQL> Rem cdgreen 07/16/04 - 10gR2
    SQL> Rem cdialeri 03/25/04 - 3516921
    SQL> Rem vbarrier 02/12/04 - 3412853
    SQL> Rem cdialeri 12/04/03 - 3290482
    SQL> Rem cdialeri 11/05/03 - 3202706
    SQL> Rem cdialeri 10/14/03 - 10g - streams - rvenkate
    SQL> Rem cdialeri 08/05/03 - 10g F3
    SQL> Rem cdialeri 02/27/03 - 10g F2: baseline, purge
    SQL> Rem vbarrier 02/25/03 - 10g RAC
    SQL> Rem cdialeri 11/15/02 - 10g F1
    SQL> Rem cdialeri 09/27/02 - sleep4
    SQL> Rem vbarrier 03/20/02 - 2143634
    SQL> Rem vbarrier 03/05/02 - Segment Statistics
    SQL> Rem cdialeri 02/07/02 - 2218573
    SQL> Rem cdialeri 01/30/02 - 2184717
    SQL> Rem cdialeri 01/11/02 - 9.2 - features 2
    SQL> Rem cdialeri 11/30/01 - 9.2 - features 1
    SQL> Rem cdialeri 04/22/01 - Undostat changes
    SQL> Rem cdialeri 03/02/01 - 9.0
    SQL> Rem cdialeri 09/12/00 - sp_1404195
    SQL> Rem cdialeri 04/07/00 - 1261813
    SQL> Rem cdialeri 03/20/00 - Support for purge
    SQL> Rem cdialeri 02/16/00 - 1191805
    SQL> Rem cdialeri 01/26/00 - 1169401
    SQL> Rem cdialeri 11/01/99 - Enhance, 1059172
    SQL> Rem cmlim 07/17/97 - Added STATS$SQLAREA to store top sql stmts
    SQL> Rem gwood 10/16/95 - Version to run as sys without using many view
    SQL> Rem cellis.uk 11/15/89 - Created
    SQL> Rem
    SQL>
    SQL> set showmode off echo off;
    If this script is automatically called from spcreate (which is
    the supported method), all STATSPACK segments will be created in
    the PERFSTAT user's default tablespace.
    Using PERFSTAT tablespace to store Statspack objects
    ... Creating STATS$SNAPSHOT_ID Sequence
    Sequence created.
    create public synonym STATS$SNAPSHOT_ID for STATS$SNAPSHOT_ID
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    Disconnected from Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    Kindly suggest on the same..
    BR

    @?/rdbms/admin/spdrop
    drop public synonym STATS$SNAPSHOT_ID;
    try again

  • Statspack Report.

    OS - win2003 server
    DB - 9.2.0.5.0
    Can you have a look on Statspack Report and offer your valuable suggestions?
    Current Instance
    ~~~~~~~~~~~~~~~~
       DB Id    DB Name      Inst Num Instance                                                                                                                                                             
      340547761 CHRYSLER            1 chrysler                                                                                                                                                             
    Instances in this Statspack schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
      340547761        1 CHRYSLER     chrysler     NOID2K36BGTP
                                                   B1
    Using  340547761 for database Id
    Using          1 for instance number
    Completed Snapshots
                               Snap                    Snap
    Instance     DB Name         Id   Snap Started    Level Comment
    chrysler     CHRYSLER         1 17 Jan 2008 10:05     5
                                  2 17 Jan 2008 10:09     5
                                  3 17 Jan 2008 10:16     5
                                  4 17 Jan 2008 10:48     5
                                  5 17 Jan 2008 11:02     5
                                  6 17 Jan 2008 11:12     5
    Specify the Begin and End Snapshot Ids
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Enter value for begin_snap: 4
    Begin Snapshot Id specified: 4
    Enter value for end_snap: 6
    End   Snapshot Id specified: 6
    PAR VERSN
    HOST_NAME                                                        DB Name
    Instance     BTIME
    NO  9.2.0.5.0
    NOID2K36BGTPB1                                                   CHRYSLER
    chrysler     20080117 10:48:11
    ETIME
    20080117 11:12:09
    Specify the Report Name
    ~~~~~~~~~~~~~~~~~~~~~~~
    The default report file name is sp_4_6.  To use this name,
    press <return> to continue, otherwise enter an alternative.
    Enter value for report_name: Statspack Report
    Using the report name Statspack Report
    SP2-0333: Illegal spool file name: "Statspack Report" (bad character: ' ')
    STATSPACK report for
    DB Name         DB Id    Instance     Inst Num Release     Cluster Host
    CHRYSLER       340547761 chrysler            1 9.2.0.5.0   NO      NOID2K36BGTP
                                                                       B1
                Snap Id     Snap Time      Sessions Curs/Sess Comment
    Begin Snap:       4 17-Jan-08 10:48:11       22       6.5
      End Snap:       6 17-Jan-08 11:12:09       27       7.4
       Elapsed:               23.97 (mins)
    Cache Sizes (end)
    ~~~~~~~~~~~~~~~~~
                   Buffer Cache:       184M      Std Block Size:         8K
               Shared Pool Size:       904M          Log Buffer:       512K
    Load Profile
    ~~~~~~~~~~~~                            Per Second       Per Transaction
                      Redo size:             10,225.13          4,901,244.00
                  Logical reads:                700.13            335,593.67
                  Block changes:                 68.68             32,918.67
                 Physical reads:                 15.03              7,206.67
                Physical writes:                 14.41              6,906.00
                     User calls:                  1.22                584.00
                         Parses:                  0.73                349.33
                    Hard parses:                  0.03                 13.67
                          Sorts:                  0.40                193.00
                         Logons:                  0.01                  4.67
                       Executes:                  1.46                701.67
                   Transactions:                  0.00
      % Blocks changed per Read:    9.81    Recursive Call %:    91.60
    Rollback per transaction %:    0.00       Rows per Sort:  1016.53
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                Buffer Nowait %:  100.00       Redo NoWait %:  100.00
                Buffer  Hit   %:   99.57    In-memory Sort %:   99.65
                Library Hit   %:  100.00        Soft Parse %:   96.09
             Execute to Parse %:   50.21         Latch Hit %:   99.98
    Parse CPU to Parse Elapsd %:   56.76     % Non-Parse CPU:   99.34
    Shared Pool Statistics        Begin   End
                 Memory Usage %:   53.83   53.90
        % SQL with executions>1:   84.54   84.53
      % Memory for SQL w/exec>1:   62.62   62.65
    Top 5 Timed Events
    ~~~~~~~~~~~~~~~~~~                                                     % Total
    Event                                               Waits    Time (s) Ela Time
    CPU time                                                           32    79.76
    direct path read                                      390           3     7.21
    db file scattered read                                275           2     3.78
    log file parallel write                               515           1     2.44
    db file sequential read                               365           1     2.07
    Wait Events for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> s  - second
    -> cs - centisecond -     100th of a second
    -> ms - millisecond -    1000th of a second
    -> us - microsecond - 1000000th of a second
    -> ordered by wait time desc, waits desc (idle events last)
                                                                       Avg
                                                         Total Wait   wait    Waits
    Event                               Waits   Timeouts   Time (s)   (ms)     /txn
    direct path read                      390          0          3      7    130.0
    db file scattered read                275          0          2      5     91.7
    log file parallel write               515        449          1      2    171.7
    db file sequential read               365          0          1      2    121.7
    control file parallel write           467          0          0      1    155.7
    control file sequential read          294          0          0      1     98.0
    db file parallel write                 35          0          0     10     11.7
    db file parallel read                   1          0          0    251      0.3
    LGWR wait for redo copy                19          1          0     12      6.3
    SQL*Net message from dblink            18          0          0      4      6.0
    latch free                             14          0          0      5      4.7
    log file sync                          14          0          0      1      4.7
    SQL*Net break/reset to clien           36          0          0      0     12.0
    log buffer space                       19          0          0      1      6.3
    SQL*Net more data to client           103          0          0      0     34.3
    direct path write                       8          0          0      1      2.7
    SQL*Net message to dblink              18          0          0      0      6.0
    SQL*Net message from client         1,606          0     11,104   6914    535.3
    wakeup time manager                    47         47      2,580  54895     15.7
    SQL*Net more data from clien           11          0          0     14      3.7
    SQL*Net message to client           1,611          0          0      0    537.0
    Background Wait Events for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> ordered by wait time desc, waits desc (idle events last)
                                                                       Avg
                                                         Total Wait   wait    Waits
    Event                               Waits   Timeouts   Time (s)   (ms)     /txn
    log file parallel write               515        449          1      2    171.7
    control file parallel write           467          0          0      1    155.7
    db file parallel write                 35          0          0     10     11.7
    control file sequential read          188          0          0      2     62.7
    LGWR wait for redo copy                19          1          0     12      6.3
    latch free                              4          0          0     17      1.3
    rdbms ipc message                   2,392      1,859      9,366   3916    797.3
    pmon timer                            487        487      2,651   5443    162.3
    smon timer                              4          4      2,307 ######      1.3
    SQL ordered by Gets for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Buffer Gets Threshold:   10000
    -> Note that resources reported for PL/SQL includes the resources used by
       all SQL statements called within the PL/SQL code.  As individual SQL
       statements are also reported, it is possible and valid for the summed
       total % to exceed 100
                                                         CPU      Elapsd
      Buffer Gets    Executions  Gets per Exec  %Total Time (s)  Time (s) Hash Value
            415,514            2      207,757.0   41.3     5.45      5.44 1116368370
    Module: SQL*Plus
    INSERT INTO STATS$SQLTEXT ( HASH_VALUE , TEXT_SUBSET , PIECE , S
    QL_TEXT , ADDRESS , COMMAND_TYPE , LAST_SNAP_ID ) SELECT ST1.HAS
    H_VALUE , SS.TEXT_SUBSET , ST1.PIECE , ST1.SQL_TEXT , ST1.ADDRES
    S , ST1.COMMAND_TYPE , SS.SNAP_ID FROM V$SQLTEXT ST1 , STATS$SQL
    SUMMARY SS WHERE SS.SNAPID = :B3 AND SS.DBID = :B2 AND SS.INST
            223,045            2      111,522.5   22.2     1.09      1.38 3446574552
    Module: SQL Developer
    select column_name from  all_updatable_columns where TABLE_NAME
    = :OBJECT_NAME and owner = :OBJECT_OWNER and updatable = 'YES'
            208,951            1      208,951.0   20.8    10.42     14.21 1240367379
    Module: SQL*Plus
    BEGIN statspack.snap ; END;
            208,539            1      208,539.0   20.7    10.47     14.11 2522684317
    Module: sqlplus.exe
    BEGIN statspack.snap; END;
             81,198            1       81,198.0    8.1     0.73      0.73  401938015
    Module: Oracle SQL Developer
    SELECT s.owner, s.synonym_name, 'SYNONYM' as object_type FROM sy
    s.all_synonyms s, sys.all_objects o WHERE s.table_name = o.objec
    t_name AND s.table_owner = o.owner AND object_type IN ('PACKAGE'
    , 'PROCEDURE', 'SEQUENCE', 'TABLE', 'TYPE', 'VIEW', 'FUNCTION' )
    ORDER BY s.owner, s.synonym_name
             58,656           10        5,865.6    5.8     3.34      3.33 3247664323
    insert into source$(obj#,line,source) values (:1,:2,:3)
             57,404            2       28,702.0    5.7     0.28      0.30 3259503395
    Module: SQL Developer
    select * from (SELECT OBJECT_NAME, OBJECT_ID ,'' short_name,
    decode(( SELECT count (1) FROM SYS.ALL_TAB_PARTITIONS WHERE TAB
    LE_OWNER =owner  AND TABLE_NAME = object_name ),0,'FALSE','TRUE'
    )  partition,                                 OWNER OBJECT_OWNER
                   FROM SYS.ALL_OBJECTS O               WHERE O.OWNE
             51,583            1       51,583.0    5.1     0.77      0.75 2077069258
    Module: Oracle SQL Developer
    SELECT owner, object_name, object_type FROM sys.all_objects WHER
    E object_type IN ('PACKAGE', 'PROCEDURE', 'SEQUENCE', 'TABLE', '
    TYPE', 'VIEW', 'FUNCTION' ) ORDER BY owner, object_name
             41,310            2       20,655.0    4.1     0.27      0.29 1607513402
    Module: SQL Developer
    SELECT OWNER,TABLE_NAME FROM all_external_tables
    SQL ordered by Gets for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Buffer Gets Threshold:   10000
    -> Note that resources reported for PL/SQL includes the resources used by
       all SQL statements called within the PL/SQL code.  As individual SQL
       statements are also reported, it is possible and valid for the summed
       total % to exceed 100
                                                         CPU      Elapsd
      Buffer Gets    Executions  Gets per Exec  %Total Time (s)  Time (s) Hash Value
             20,776            1       20,776.0    2.1     0.20      0.21 1305228895
    Module: SQL*Plus
    select owner , object_name , object_type from dba_objects where
    object_type = 'TABLE'
             15,709           10        1,570.9    1.6     0.97      1.07 3098922061
    delete from source$ where obj#=:1
             11,854            1       11,854.0    1.2     0.11      0.21 4208944292
    Module: SQL Developer
    with pri_cols as ( SELECT cols.column_name column_name, cols.pos
    ition column_position              FROM all_constraints cons, al
    l_cons_columns cols            WHERE cons.constraint_type = 'P'
               AND cons.constraint_name = cols.constraint_name
          AND cons.owner = cols.owner            and cols.table_name
              7,493            1        7,493.0    0.7     0.17      1.87 1279266739
    Module: SQL Developer
    select count(*) from IMP_TEMPSS_PARTSLANG
              3,904           47           83.1    0.4     0.00      0.14  815501214
    select t.schema, t.name, t.flags, q.name from system.aq$_queue_t
    ables t, sys.aq$_queue_table_affinities aft,      system.aq$_que
    ues q where aft.table_objno = t.objno and aft.owner_instance = :
    1 and        q.table_objno = t.objno and q.usage = 0 and       b
    itand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name, aft
              3,467           14          247.6    0.3     0.50      0.53 1554250272
    Module: SQL Developer
    select count(1) from all_objects where owner <> 'PUBLIC' and  ob
    ject_name in (:S0)
              1,694            4          423.5    0.2     0.08      0.08 1547382267
    Module: SQL Developer
    select object_type,owner,object_name,rank from (    select objec
    t_type,owner,object_name,0 rank    from all_objects    where obj
    ect_name = :NAME    and UPPER(owner) = nvl(:OWNER,UPPER(sys_cont
    ext('USERENV', 'CURRENT_SCHEMA')))    and object_type not in ( '
    SYNONYM' )     union all    select ao.object_type,ao.owner,ao.ob
              1,317          188            7.0    0.1     0.00      0.03 3371479671
    select t.name,  (select owner_instance from sys.aq$_queue_table_
    affinities   where table_objno = t.objno)  from system.aq$_queue
    _tables t where t.name = :1 and t.schema = :2 for update skip lo
    cked
                892            1          892.0    0.1     0.02      0.01 3021556466
    Module: SQL Developer
    SELECT OBJECT_NAME, OBJECT_ID,             DECODE(STATUS, 'INVAL
    ID', 'TRUE', 'FALSE') INVALID,              'TRUE' runnable,
    SQL ordered by Gets for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Buffer Gets Threshold:   10000
    -> Note that resources reported for PL/SQL includes the resources used by
       all SQL statements called within the PL/SQL code.  As individual SQL
       statements are also reported, it is possible and valid for the summed
       total % to exceed 100
                                                         CPU      Elapsd
      Buffer Gets    Executions  Gets per Exec  %Total Time (s)  Time (s) Hash Value
             NVL( b.HAS_BODY, 'FALSE') HAS_BODY FROM SYS.ALL_OBJECTS
    a,      (SELECT 'TRUE' HAS_BODY, object_name tmp_name FROM SYS.
    ALL_OBJECTS WHERE OWNER = :SCHEMA AND OBJECT_TYPE = 'PACKAGE BOD
                890            2          445.0    0.1     0.09      0.10 1201167771
    Module: SQL Developer
    SELECT T.TABLE_NAME,     'TABLE' OBJECT_TYPE ,     (SELECT O.OBJ
    ECT_ID        FROM ALL_OBJECTS O        WHERE O.OWNER = T.OWNER
           AND O.OBJECT_TYPE = 'TABLE'        AND O.OBJECT_NAME = T.
    TABLE_NAME) OBJECT_ID FROM   ALL_TABLES T WHERE  T.OWNER = :1 AN
    D    T.TABLE_NAME LIKE :2 AND    T.IOT_NAME IS NULL AND    T.NES
                779           10           77.9    0.1     0.02      0.05 3067006941
    delete from dependency$ where d_obj#=:1
                748          146            5.1    0.1     0.05      0.05 3951809012
    insert into dependency$(d_obj#,d_timestamp,order#,p_obj#,p_times
    tamp,d_owner#, property)values (:1,:2,:3,:4,:5,:6, :7)
                632            2          316.0    0.1    10.53     17.92 4043595143
    Module: SQL*Plus
    INSERT INTO STATS$SQL_SUMMARY ( SNAP_ID , DBID , INSTANCE_NUMBER
    , TEXT_SUBSET , SHARABLE_MEM , SORTS , MODULE , LOADED_VERSIONS
    SQL ordered by Reads for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Disk Reads Threshold:    1000
                                                         CPU      Elapsd
    Physical Reads  Executions  Reads per Exec %Total Time (s)  Time (s) Hash Value
             17,317            2        8,658.5   80.1    10.53     17.92 4043595143
    Module: SQL*Plus
    INSERT INTO STATS$SQL_SUMMARY ( SNAP_ID , DBID , INSTANCE_NUMBER
    , TEXT_SUBSET , SHARABLE_MEM , SORTS , MODULE , LOADED_VERSIONS
    , FETCHES , EXECUTIONS , LOADS , INVALIDATIONS , PARSE_CALLS ,
    DISK_READS , BUFFER_GETS , ROWS_PROCESSED , COMMAND_TYPE , ADDRE
    SS , HASH_VALUE , VERSION_COUNT , CPU_TIME , ELAPSED_TIME , OUTL
              8,659            1        8,659.0   40.1    10.42     14.21 1240367379
    Module: SQL*Plus
    BEGIN statspack.snap ; END;
              8,658            1        8,658.0   40.0    10.47     14.11 2522684317
    Module: sqlplus.exe
    BEGIN statspack.snap; END;
              3,880            1        3,880.0   17.9     0.17      1.87 1279266739
    Module: SQL Developer
    select count(*) from IMP_TEMPSS_PARTSLANG
                299            2          149.5    1.4     1.09      1.38 3446574552
    Module: SQL Developer
    select column_name from  all_updatable_columns where TABLE_NAME
    = :OBJECT_NAME and owner = :OBJECT_OWNER and updatable = 'YES'
                 12            5            2.4    0.1     0.05      0.13 3444463493
    Module: SQL Developer
    SELECT TEXT FROM SYS.ALL_SOURCE  WHERE TYPE = :TYPE AND OWNER =
    :OWNER AND NAME = :NAME  ORDER BY LINE
                 12            4            3.0    0.1     0.03      0.13 3833423502
    Module: SQL Developer
    SELECT TEXT FROM SYS.ALL_SOURCE WHERE TYPE = :1 AND OWNER = :2 A
    ND NAME = :3 ORDER BY LINE
                  9            1            9.0    0.0     0.00      0.07 3687727603
    insert into col$(obj#,name,intcol#,segcol#,type#,length,precisio
    n#,scale,null$,offset,fixedstorage,segcollength,deflength,defaul
    t$,col#,property,charsetid,charsetform,spare1,spare2,spare3)valu
    es(:1,:2,:3,:4,:5,:6,decode(:7,0,null,:7),decode(:5,2,decode(:8,
    -127/*MAXSB1MINAL*/,null,:8),178,:8,179,:8,180,:8,181,:8,182,:8,
                  8            2            4.0    0.0     0.28      0.30 3259503395
    Module: SQL Developer
    select * from (SELECT OBJECT_NAME, OBJECT_ID ,'' short_name,
    decode(( SELECT count (1) FROM SYS.ALL_TAB_PARTITIONS WHERE TAB
    LE_OWNER =owner  AND TABLE_NAME = object_name ),0,'FALSE','TRUE'
    )  partition,                                 OWNER OBJECT_OWNER
                   FROM SYS.ALL_OBJECTS O               WHERE O.OWNE
                  7            5            1.4    0.0     0.02      0.06 3508476732
    insert into idl_ub1$(obj#,part,version,piece#,length,piece) valu
    es(:1,:2,:3,:4,:5,:6)
    SQL ordered by Reads for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Disk Reads Threshold:    1000
                                                         CPU      Elapsd
    Physical Reads  Executions  Reads per Exec %Total Time (s)  Time (s) Hash Value
                  5            8            0.6    0.0     0.00      0.03 1008661772
    update idl_ub1$ set piece#=:1 ,length=:2 , piece=:3 where obj#=:
    4 and part=:5 and piece#=:6 and version=:7
                  5            1            5.0    0.0     0.11      0.21 4208944292
    Module: SQL Developer
    with pri_cols as ( SELECT cols.column_name column_name, cols.pos
    ition column_position              FROM all_constraints cons, al
    l_cons_columns cols            WHERE cons.constraint_type = 'P'
               AND cons.constraint_name = cols.constraint_name
          AND cons.owner = cols.owner            and cols.table_name
                  2            3            0.7    0.0     0.00      0.01  761440199
    insert into idl_ub2$(obj#,part,version,piece#,length,piece) valu
    es(:1,:2,:3,:4,:5,:6)
                  1            3            0.3    0.0     0.00      0.01 1249304535
    update idl_ub2$ set piece#=:1 ,length=:2 , piece=:3 where obj#=:
    4 and part=:5 and piece#=:6 and version=:7
                  1            2            0.5    0.0     0.27      0.29 1607513402
    Module: SQL Developer
    SELECT OWNER,TABLE_NAME FROM all_external_tables
                  1           10            0.1    0.0     0.03      0.02 1825174980
    delete from access$ where d_obj#=:1
                  1           10            0.1    0.0     0.02      0.05 3067006941
    delete from dependency$ where d_obj#=:1
                  1           10            0.1    0.0     3.34      3.33 3247664323
    insert into source$(obj#,line,source) values (:1,:2,:3)
                  1          146            0.0    0.0     0.05      0.05 3951809012
    insert into dependency$(d_obj#,d_timestamp,order#,p_obj#,p_times
    tamp,d_owner#, property)values (:1,:2,:3,:4,:5,:6, :7)
                  0            2            0.0    0.0     0.00      0.00   10821553
    Module: SQL Developer
    ALTER SESSION SET TIME_ZONE = '05:30'
                  0            3            0.0    0.0     0.00      0.01   66972507
    Module: SQL Developer
    SELECT TO_DATE(TIMESTAMP, 'YYYY-MM-DD:HH24:MI:SS') FROM SYS.ALL_
    OBJECTS WHERE OWNER = :1 AND OBJECT_NAME = :2 AND OBJECT_TYPE =
    :3
                  0            2            0.0    0.0     0.02      0.00   80089551
    Module: SQL Developer
    SELECT LAST_DDL_TIME FROM SYS.ALL_OBJECTS WHERE OWNER = :1 AND O
    BJECT_NAME = :2 AND OBJECT_TYPE = :3
                  0            1            0.0    0.0     0.00      0.00  120978412
    select col#,intcol#,ntab# from ntab$ where obj#=:1 order by intc
    SQL ordered by Reads for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Disk Reads Threshold:    1000
                                                         CPU      Elapsd
    Physical Reads  Executions  Reads per Exec %Total Time (s)  Time (s) Hash Value
    ol# asc
                  0            5            0.0    0.0     0.00      0.00  130926350
    select count(*) from sys.job$ where next_date < :1 and (field1 =
    :2 or (field1 = 0 and 'Y' = :3))
                  0            5            0.0    0.0     0.00      0.00  155765854
    select count(*),min(piece#),max(piece#) from idl_ub1$ where obj#
    =:1 and part=:2 and version=:3
                  0            1            0.0    0.0     0.00      0.00  162044583
    select col#,intcol#,charsetid,charsetform from col$ where obj#=:
    1 order by intcol# asc
                  0            2            0.0    0.0     0.00      0.00  179957765
    select count(*),min(piece#),max(piece#) from idl_char$ where obj
    #=:1 and part=:2 and version=:3
                  0            3            0.0    0.0     0.00      0.00  204386021
    select col#, grantee#, privilege#,max(mod(nvl(option$,0),2)) fro
    m objauth$ where obj#=:1 and col# is not null group by privilege
    #, col#, grantee# order by col#, grantee#
                  0           10            0.0    0.0     0.00      0.00  292617943
    delete from vtable$ where obj#=:1
                  0            1            0.0    0.0     0.73      0.73  401938015
    Module: Oracle SQL Developer
    SELECT s.owner, s.synonym_name, 'SYNONYM' as object_type FROM sy
    SQL ordered by Executions for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Executions Threshold:     100
                                                    CPU per    Elap per
    Executions   Rows Processed   Rows per Exec    Exec (s)   Exec (s)  Hash Value
             280               0              0.0       0.00        0.00 1316169839
    select job, nvl2(last_date, 1, 0) from sys.job$ where (((:1 <= n
    ext_date) and (next_date < :2))    or  ((last_date is null) and
    (next_date < :3))) and (field1 = :4 or (field1 = 0 and 'Y' = :5)
    ) and (this_date is null) order by next_date, job
             280             280              1.0       0.00        0.00 1693927332
    select count(*) from sys.job$ where (next_date > sysdate) and (n
    ext_date < (sysdate+5/86400))
             188             188              1.0       0.00        0.00 3371479671
    select t.name,  (select owner_instance from sys.aq$_queue_table_
    affinities   where table_objno = t.objno)  from system.aq$_queue
    _tables t where t.name = :1 and t.schema = :2 for update skip lo
    cked
             146             146              1.0       0.00        0.00 3951809012
    insert into dependency$(d_obj#,d_timestamp,order#,p_obj#,p_times
    tamp,d_owner#, property)values (:1,:2,:3,:4,:5,:6, :7)
              76              76              1.0       0.00        0.00 2997854589
    insert into access$(d_obj#,order#,columns,types) values (:1,:2,:
    3,:4)
              47               0              0.0       0.00        0.00  633914867
    select q_name, state, delay, expiration, rowid, msgid,    dequeu
    e_msgid, chain_no, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corr
    id,     time_manager_info   from SYS.AQ_EVENT_TABLE   where time
    managerinfo <= :1 and state != :2   for update skip locked
              47             188              4.0       0.00        0.00  815501214
    select t.schema, t.name, t.flags, q.name from system.aq$_queue_t
    ables t, sys.aq$_queue_table_affinities aft,      system.aq$_que
    ues q where aft.table_objno = t.objno and aft.owner_instance = :
    1 and        q.table_objno = t.objno and q.usage = 0 and       b
    itand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name, aft
              47               0              0.0       0.00        0.00  870116171
    select q_name, state, delay, expiration, rowid, msgid,    dequeu
    e_msgid, chain_no, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corr
    id,     time_manager_info   from SYSTEM.DEF$_AQERROR   where tim
    e_manager_info <= :1 and state != :2   for update skip locked
              47               0              0.0       0.00        0.00 1153132087
    select q_name, state, delay, expiration, rowid, msgid,    dequeu
    e_msgid, chain_no, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corr
    id,     time_manager_info   from SYSTEM.DEF$_AQCALL   where time
    managerinfo <= :1 and state != :2   for update skip locked
              47               0              0.0       0.00        0.00 3920324236
    select q_name, state, delay, expiration, rowid, msgid,   dequeue
    SQL ordered by Executions for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Executions Threshold:     100
                                                    CPU per    Elap per
    Executions   Rows Processed   Rows per Exec    Exec (s)   Exec (s)  Hash Value
    msgid, chainno, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corri
    d,   time_manager_info, sender_name, sender_address, sender_prot
    ocol   from SYS.AQ_SRVNTFN_TABLE   where time_manager_info <= :1
              30              30              1.0       0.00        0.00 2201541053
    insert into error$(obj#,sequence#,line,position#,textlength,text
    ) values (:1,:2,:3,:4,:5,:6)
              26             115              4.4       0.00        0.00 1749333492
    select position#,sequence#,level#,argument,type#,charsetid,chars
    etform,properties,nvl(length, 0), nvl(precision#, 0),nvl(scale,
    0),nvl(radix, 0), type_owner,type_name,type_subname,type_linknam
    e,pls_type from argument$ where obj#=:1 and procedure#=:2 order
    by sequence# desc
              21               0              0.0       0.00        0.00 1683508596
    delete from idl_sb4$ where obj#=:1 and part=:2
              21               0              0.0       0.00        0.00 1894783783
    delete from idl_char$ where obj#=:1 and part=:2
              21               0              0.0       0.00        0.00 2479503691
    delete from idl_ub1$ where obj#=:1 and part=:2
              21               0              0.0       0.00        0.00 3926364396
    delete from idl_ub2$ where obj#=:1 and part=:2
              20              20              1.0       0.00        0.00 3401267293
    insert into settings$(obj#, param, value) values (:1, :2, :3)
              14              62              4.4       0.00        0.00 1356713530
    select privilege#,level from sysauth$ connect by grantee#=prior
    privilege# and privilege#>0 start with (grantee#=:1 or grantee#=
    1) and privilege#>0
              14              14              1.0       0.04        0.04 1554250272
    Module: SQL Developer
    select count(1) from all_objects where owner <> 'PUBLIC' and  ob
    ject_name in (:S0)
              13              13              1.0       0.00        0.00 3468666020
    select text from view$ where rowid=:1
              12              12              1.0       0.00        0.00  825987371
    Module: SQL Developer
    declare     l_line varchar2(255);     l_done number;     l_buffe
    r long; begin   loop     exit when length(l_buffer)+255 > :maxby
    tes OR l_done = 1;     dbms_output.get_line( l_line, l_done );
       l_buffer := l_buffer || l_line || chr(10);   end loop;  :done
    := l_done;  :buffer := l_buffer; end;
              12               0              0.0       0.00        0.00 2222871512
    Module: SQL Developer
    SQL ordered by Executions for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Executions Threshold:     100
                                                    CPU per    Elap per
    Executions   Rows Processed   Rows per Exec    Exec (s)   Exec (s)  Hash Value
    SELECT LINE,POSITION,TEXT FROM USER_ERRORS WHERE TYPE=:1AND NAME
    =:2
    SQL ordered by Parse Calls for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Parse Calls Threshold:      1000
                               % Total
    Parse Calls  Executions   Parses  Hash Value
              47           47     4.48  633914867
    select q_name, state, delay, expiration, rowid, msgid,    dequeu
    e_msgid, chain_no, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corr
    id,     time_manager_info   from SYS.AQ_EVENT_TABLE   where time
    managerinfo <= :1 and state != :2   for update skip locked
              47           47     4.48  815501214
    select t.schema, t.name, t.flags, q.name from system.aq$_queue_t
    ables t, sys.aq$_queue_table_affinities aft,      system.aq$_que
    ues q where aft.table_objno = t.objno and aft.owner_instance = :
    1 and        q.table_objno = t.objno and q.usage = 0 and       b
    itand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name, aft
              47           47     4.48  870116171
    select q_name, state, delay, expiration, rowid, msgid,    dequeu
    e_msgid, chain_no, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corr
    id,     time_manager_info   from SYSTEM.DEF$_AQERROR   where tim
    e_manager_info <= :1 and state != :2   for update skip locked
              47           47     4.48 1153132087
    select q_name, state, delay, expiration, rowid, msgid,    dequeu
    e_msgid, chain_no, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corr
    id,     time_manager_info   from SYSTEM.DEF$_AQCALL   where time
    managerinfo <= :1 and state != :2   for update skip locked
              47          188     4.48 3371479671
    select t.name,  (select owner_instance from sys.aq$_queue_table_
    affinities   where table_objno = t.objno)  from system.aq$_queue
    _tables t where t.name = :1 and t.schema = :2 for update skip lo
    cked
              47           47     4.48 3920324236
    select q_name, state, delay, expiration, rowid, msgid,   dequeue
    msgid, chainno, local_order_no, enq_time, enq_tid, step_no,
    priority, exception_qschema, exception_queue, retry_count, corri
    d,   time_manager_info, sender_name, sender_address, sender_prot
    ocol   from SYS.AQ_SRVNTFN_TABLE   where time_manager_info <= :1
              21           21     2.00 1683508596
    delete from idl_sb4$ where obj#=:1 and part=:2
              21           21     2.00 1894783783
    delete from idl_char$ where obj#=:1 and part=:2
              21           21     2.00 2479503691
    delete from idl_ub1$ where obj#=:1 and part=:2
              21           21     2.00 3926364396
    delete from idl_ub2$ where obj#=:1 and part=:2
              14           14     1.34 1356713530
    SQL ordered by Parse Calls for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Parse Calls Threshold:      1000
                               % Total
    Parse Calls  Executions   Parses  Hash Value
    select privilege#,level from sysauth$ connect by grantee#=prior
    privilege# and privilege#>0 start with (grantee#=:1 or grantee#=
    1) and privilege#>0
              14           14     1.34 1554250272
    Module: SQL Developer
    select count(1) from all_objects where owner <> 'PUBLIC' and  ob
    ject_name in (:S0)
              13           13     1.24 3468666020
    select text from view$ where rowid=:1
              12           12     1.15  825987371
    Module: SQL Developer
    declare     l_line varchar2(255);     l_done number;     l_buffe
    r long; begin   loop     exit when length(l_buffer)+255 > :maxby
    tes OR l_done = 1;     dbms_output.get_line( l_line, l_done );
       l_buffer := l_buffer || l_line || chr(10);   end loop;  :done
    := l_done;  :buffer := l_buffer; end;
              12           12     1.15 2222871512
    Module: SQL Developer
    SELECT LINE,POSITION,TEXT FROM USER_ERRORS WHERE TYPE=:1AND NAME
    =:2
              11           11     1.05  701589132
    Module: SQL Developer
    BEGIN       /* NOP UNLESS A TABLE OBJECT */       IF dictionary_
    obj_type = 'TABLE' AND sys.dbms_cdc_publish.active > 0       THE
    N         sys.dbms_cdc_publish.change_table_trigger(dictionary_o
    bj_owner,dictionary_obj_name,sysevent);       END IF;       END;
              11           11     1.05 4144490151
    delete from error$ where obj#=:1
              11           11     1.05 4151580176
    update obj$ set obj#=:6,type#=:7,ctime=:8,mtime=:9,stime=:10,sta
    tus=:11,dataobj#=:13,flags=:14,oid$=:15,spare1=:16, spare2=:17 w
    here owner#=:1 and name=:2 and namespace=:3 and(remoteowner=:4 o
    r remoteowner is null and :4 is null)and(linkname=:5 or linkname
    is null and :5 is null)and(subname=:12 or subname is null and :
              10           10     0.95  292617943
    delete from vtable$ where obj#=:1
              10           10     0.95  412513799
    select o.owner#, u.name,        o.name,            o.namespace,
            o.obj#,   d.d_timestamp, nvl(d.property,0), o.type#, o.s
    ubname  from dependency$ d, obj$ o, user$ u  where d.p_obj#=:1
    and   (d.p_timestamp=:2 or d.property=2)  and   d.d_obj#=o.obj#
    and   o.owner#=u.user#  and decode(:3,0,0,o.type#)=:3
              10           10     0.95 1077743770
    SQL ordered by Parse Calls for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Parse Calls Threshold:      1000
                               % Total
    Parse Calls  Executions   Parses  Hash Value
    delete from argument$ where obj#=:1
    SQL ordered by Sharable Memory for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Sharable Memory Threshold:   1048576
    Sharable Mem (b)  Executions  % Total  Hash Value
           3,898,908            2     0.4   3259503395
    Module: SQL Developer
    select * from (SELECT OBJECT_NAME, OBJECT_ID ,'' short_name,
    decode(( SELECT count (1) FROM SYS.ALL_TAB_PARTITIONS WHERE TAB
    LE_OWNER =owner  AND TABLE_NAME = object_name ),0,'FALSE','TRUE'
    )  partition,                                 OWNER OBJECT_OWNER
                   FROM SYS.ALL_OBJECTS O               WHERE O.OWNE
           2,519,473            1     0.3    680078008
    Module: SQL Developer
    SELECT O.OBJECT_NAME, O.OBJECT_TYPE, O.OBJECT_ID FROM   ALL_OBJE
    CTS O WHERE  O.OWNER = :1 AND    O.OBJECT_NAME LIKE :2 AND    O.
    OBJECT_TYPE IN (:3) AND    O.SUBOBJECT_NAME IS NULL AND    O.SEC
    ONDARY = 'N' AND    ( O.OBJECT_TYPE <> 'INDEX' OR         (
          EXISTS (SELECT 1                   FROM   ALL_INDEXES I
           1,882,420            1     0.2   4208944292
    Module: SQL Developer
    with pri_cols as ( SELECT cols.column_name column_name, cols.pos
    ition column_position              FROM all_constraints cons, al
    l_cons_columns cols            WHERE cons.constraint_type = 'P'
               AND cons.constraint_name = cols.constraint_name
          AND cons.owner = cols.owner            and cols.table_name
           1,687,994            4     0.2   1547382267
    Module: SQL Developer
    select object_type,owner,object_name,rank from (    select objec
    t_type,owner,object_name,0 rank    from all_objects    where obj
    ect_name = :NAME    and UPPER(owner) = nvl(:OWNER,UPPER(sys_cont
    ext('USERENV', 'CURRENT_SCHEMA')))    and object_type not in ( '
    SYNONYM' )     union all    select ao.object_type,ao.owner,ao.ob
           1,406,016            2     0.1   2033073833
    Module: SQL Developer
    select parameter,value from nls_session_parameters  union all SE
    LECT 'DB_TIMEZONE' name, DBTIMEZONE  value FROM DUAL union all S
    ELECT parameter, value FROM nls_database_parameters WHERE parame
    ter='NLS_CHARACTERSET'
    SQL ordered by Version Count for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    -> End Version Count Threshold:        20
    Version
       Count  Executions   Hash Value
          53            2   2033073833
    Module: SQL Developer
    select parameter,value from nls_session_parameters  union all SE
    LECT 'DB_TIMEZONE' name, DBTIMEZONE  value FROM DUAL union all S
    ELECT parameter, value FROM nls_database_parameters WHERE parame
    ter='NLS_CHARACTERSET'
    Instance Activity Stats for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    Statistic                                      Total     per Second    per Trans
    CPU used by this session                       3,185            2.2      1,061.7
    CPU used when call started                     3,185            2.2      1,061.7
    CR blocks created                                 48            0.0         16.0
    Cached Commit SCN referenced                       0            0.0          0.0
    Commit SCN cached                                  0            0.0          0.0
    DBWR buffers scanned                               0            0.0          0.0
    DBWR checkpoint buffers written                   22            0.0          7.3
    DBWR checkpoints                                   0            0.0          0.0
    DBWR free buffers found                            0            0.0          0.0
    DBWR lru scans                                     0            0.0          0.0
    DBWR make free requests                            0            0.0          0.0
    DBWR revisited being-written buff                  0            0.0          0.0
    DBWR summed scan depth                             0            0.0          0.0
    DBWR transaction table writes                      6            0.0          2.0
    DBWR undo block writes                            12            0.0          4.0
    SQL*Net roundtrips to/from client              1,570            1.1        523.3
    SQL*Net roundtrips to/from dblink                 18            0.0          6.0
    active txn count during cleanout                 188            0.1         62.7
    background checkpoints completed                   0            0.0          0.0
    background checkpoints started                     0            0.0          0.0
    background timeouts                            1,682            1.2        560.7
    branch node splits                                 0            0.0          0.0
    buffer is not pinned count                   436,985          303.9    145,661.7
    buffer is pinned count                       948,328          659.5    316,109.3
    bytes received via SQL*Net from c            803,800          559.0    267,933.3
    bytes received via SQL*Net from d              6,405            4.5      2,135.0
    bytes sent via SQL*Net to client             831,677          578.4    277,225.7
    bytes sent via SQL*Net to dblink               3,735            2.6      1,245.0
    calls to get snapshot scn: kcmgss              7,027            4.9      2,342.3
    calls to kcmgas                                  763            0.5        254.3
    calls to kcmgcs                                  208            0.1         69.3
    change write time                                375            0.3        125.0
    cleanout - number of ktugct calls              3,728            2.6      1,242.7
    cleanouts and rollbacks - consist                  0            0.0          0.0
    cleanouts only - consistent read               3,527            2.5      1,175.7
    cluster key scan block gets                   27,451           19.1      9,150.3
    cluster key scans                             12,274            8.5      4,091.3
    commit cleanout failures: block l                  0            0.0          0.0
    commit cleanout failures: buffer                   0            0.0          0.0
    commit cleanout failures: callbac                  2            0.0          0.7
    commit cleanout failures: cannot                   0            0.0          0.0
    commit cleanouts                               1,219            0.9        406.3
    commit cleanouts successfully com              1,217            0.9        405.7
    commit txn count during cleanout               3,574            2.5      1,191.3
    consistent changes                                95            0.1         31.7
    consistent gets                              926,553          644.3    308,851.0
    consistent gets - examination                304,799          212.0    101,599.7
    current blocks converted for CR                    0            0.0          0.0
    cursor authentications                            13            0.0          4.3
    data blocks consistent reads - un                 95            0.1         31.7
    db block changes                              98,756           68.7     32,918.7
    db block gets                                 80,228           55.8     26,742.7
    deferred (CURRENT) block cleanout                613            0.4        204.3
    dirty buffers inspected                        3,379            2.4      1,126.3
    enqueue conversions                               90            0.1         30.0
    enqueue releases                               2,288            1.6        762.7
    Instance Activity Stats for DB: CHRYSLER  Instance: chrysler  Snaps: 4 -6
    Statistic                                      Total     per Second    per Trans
    enqueue requests                               2,290            1.6        763.3
    enqueue timeouts                                   0            0.0          0.0
    enqueue waits                                      0            0.0          0.0
    execute count                                  2,105            1.5        701.7
    free buffer inspected                          3,379            2.4      1,126.3
    free buffer requested                          4,937            3.4      1,645.7
    hot buffers moved to head of LRU                 243            0.2         81.0
    immediate (CR) block cleanout app              3,527            2.5      1,175.7
    immediate (CURRENT) block cleanou                240            0.2         80.0
    index fast full scans (full)                       0            0.0          0.0
    index fetch by key                           248,987          173.2     82,995.7
    index scans kdiixs1                          457,728          318.3    152,576.0
    leaf node 90-10 splits                             1            0.0          0.3
    leaf node splits                                  36            0.0         12.0
    logons cumulative                                 14            0.0          4.7
    messages received                                553            0.4        184.3
    messages sent                                    553            0.4        184.3
    no buffer to keep pinned count                     0            0.0          0.0
    no work - consistent read gets               483,400          336.2    161,133.3
    opened cursors cumulative                        806            0.6        268.7
    parse count (failures)                            14            0.0          4.7
    parse count (hard)                                41            0.0         13.7
    parse count (total)                            1,048            0.7        349.3
    parse time cpu                                    21            0.0          7.0
    parse time elapsed                                37            0.0         12.3
    physical reads                                21,620           15.0      7,206.7
    physical reads direct                         17,317           12.0      5,772.3
    physical writes                               20,718           14.4      6,906.0
    physical writes direct                        17,317           12.0      5,772.3
    physical writes non checkpoint                20,698           14.4      6,899.3
    pinned buffers inspected                           0            0.0          0.0
    prefetched blocks                              3,662            2.6      1,220.7
    prefetched blocks aged out before                  0            0.0          0.0
    process last non-idle time            16,807,669,922   11,688,226.7 ############
    recovery blocks read                               0            0.0          0.0
    recursive calls                               19,103           13.3      6,367.7
    recursive cpu usage                            2,568            1.8        856.0
    redo blocks written                           29,780           20.7      9,926.7
    redo buffer allocation retries                    19            0.0          6.3
    redo entries                                  51,190           35.6     17,063.3
    redo log space requests                            0            0.0          0.0
    redo log space wait time                           0            0.0          0.0
    redo ordering marks                               17            0.0          5.7
    redo size                   

    I know, I must apply the latest patch to make it 9.2.0.8.0. coming back to your question, I am actually new in this company, don't know much about their nature of database. their database appears to run prety slow. specially, when they perfrom bulk DML activity. I've already suggested them to disable the indexes
    and drop the constraints, but that didn't seem to work eighter. I though, you guys would able to offer something , which would make sence in order to kill the ongoing problem. Anyways, thanks for the inputs
    hare krishna
    Alok

  • Statspack: error with spcreate.sql in 11.1.0.7 on WIndows

    Hello,
    I'm trying to install statspack on a 11.1.0.7 64bit RDBMS on Windows 2008 R2.
    I get this error during spcreate.sql as sysdba
    ... Creating views
    . quisce_t*drms quiesce_time
    ERROR at line 5
    ORA-00904: "QUISCE_T" : invalid identifier
    I wasn't able to find anything related on metalink....
    Any hint?
    I was previously able to run it on 11.2.0.1 and 11.2.0.3 RDBMS on Linux systems...
    I don't know if it is a problem with this particular version of the rdbms.
    Thanks in advance,
    Gianluca

    hello,
    running now a snap as perfstat user I get this error
    SQL> exec statspack.snap;
    BEGIN statspack.snap; END;
    ERROR at line 1:
    ORA-04063: package body "SYS.DBMS_SHARED_POOL" has errors
    ORA-06508: PL/SQL: could not find program unit being called:
    "SYS.DBMS_SHARED_POOL"
    ORA-06512: at "PERFSTAT.STATSPACK", line 5767
    ORA-06512: at line 1
    In fact
    SQL> select owner,object_name,object_type from dba_objects where status='INVALID
    2 order by object_name;
    OWNER OBJECT_NAME OBJECT_TYPE
    SYS DBMS_SHARED_POOL PACKAGE BODY
    PUBLIC STATSPACK SYNONYM
    Trying to recompile as sysdba I get
    Connected to:
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    SQL> alter package dbms_shared_pool compile body;
    Warning: Package Body altered with compilation errors.
    SQL> show errors
    Errors for PACKAGE BODY DBMS_SHARED_POOL:
    LINE/COL ERROR
    87/13 PLS-00323: subprogram or cursor 'PURGE' is declared in a package
    specification and must be defined in the package body
    Could it be that t was my first 10.2.0.3 spcreate.sql putting the package in this state?
    I don't suppose so and that the package was already invalid before... but not sure...
    How to correct? I found similar cases where Oracle oly suggested catalog/catproc runs... but I would like to avoid if possible...
    Thanks in advance

  • Statspack installation

    Hi,
    I am trying to install statspack....Almost at the end of installtion I am getting ORA-04031 error
    Creating Package Body STATSPACK
    create or replace package body STATSPACK as
    ERROR at line :1
    ORA-04031:unable to allocate 4096 bytes of shared memory("shared
    pool","unknown object ","PL/SQLMPCODE","BAMIMA:Bam buffer").
    What could be the possible solution for this?
    Thanks,

    $ oerr ORA 04031
    04031, 00000, "unable to allocate %s bytes of shared memory (\"%s\",\"%s\",\"%s\",\"%s\")"
    // *Cause:  More shared memory is needed than was allocated in the shared
    //          pool.
    // *Action: If the shared pool is out of memory, either use the
    //          dbms_shared_pool package to pin large packages,
    //          reduce your use of shared memory, or increase the amount of
    //          available shared memory by increasing the value of the
    //          INIT.ORA parameters "shared_pool_reserved_size" and
    //          "shared_pool_size".
    //          If the large pool is out of memory, increase the INIT.ORA
    //          parameter "large_pool_size".sorry for duplicity post
    Message was edited by:
    Ivan Kartik

  • Poor performance when running DBMS_STATS package

    Hello,
    I thought I would throw this issue out to the general population as I am stumped.
    I have two identical schemas on two different severs. Database in 9.2.0.6 and for QAS and Production reasons the servers and database settings are identical.
    I am running the DBMS_STATS.GATHER_SCHEMA_STATS package on both databases. On the QAS DB it takes roughly 1.5 hours while on the Production database it takes 8.0 hours.
    Looking at the statspack analysis, the biggest thing to jump out at me is that the temporary tablespace is getting 4.6 Million I/O hits (reads) while the QAS is only getting a few thousand.
    So .... this sort of indicates that something is going on in the PGA which could cause Oracle to use the TEMP tablespace. However when I look in the host performance (using Grid Control) the servers memory, file I/O, and CPU while high are not over 80%.
    Has anyone else seen and issue like this? Any ideas where to look?
    Thanks,
    Chris

    To the extent that you are gathering histograms on the data, Oracle potentially has to do a reasonable amount of sorting. If one machine has substantially more physical RAM, that presumably implies that it has more RAM available for the PGA, which would allow more sorts to happen in memory rather than on disk.
    Depending on how you create a "refresh copy of production" and what parameters you are passing in to DBMS_STATS, it is also possible that the quality assurance database is gathering substantially more histograms than the production database (i.e. you refresh lower environments via export and import rather than doing an RMAN clone and tell Oracle to gather histograms on any columns that currently have histograms).
    Justin

  • After Statspack Install Logical DB stopped - urgent

    Oracle 10.2.0.1.0
    After installing statspack @spcreate installed sucessfully
    @spauto create job sucessfully
    But the Logical stdby stopped applying the logs with the following error message
    alert.log
    ================
    LOGSTDBY stmt: grant execute on dbms_shared_pool to execute_catalog_role
    LOGSTDBY status: ORA-04042: procedure, function, package, or package body does not exist
    LOGSTDBY id: XID 0x000d.01b.00009d72, hSCN 0x0000.20c7cf14, lSCN 0x0000.20c7cf14, Thread 1, RBA
    0x6642.0000433b.138, txnCscn 0x0000.20c7cf17, PID 5544, ORACLE.EXE
    (P006)
    LOGSTDBY Apply process P006 pid=45 OS id=5544 stopped
    Wed Dec 19 16:13:10 2007
    ================
    Please help if anyone has any idea on this forum, how do i start the logs applying the to logical standby.
    Thanks

    Hi reega,
    Thanks for your reply, our logical stdby has '+RT06_DATA/RT06'
    and primary has '+OT06_DATA/OT06TSG001'
    so we are using db_file_name_convert init parameter but it doesn't work.
    Is there any thing particular steps hiding to use this parameter? as i tried this parameter for rman cloning it din't work, as a workaround i used rman set new name command for clonning.
    Let me know if you have any questions.
    Thanks in advance.

Maybe you are looking for

  • Itunes wont download songs from other countries

    i would like to download songs from different countries but says "itunes could not connect to the music store an unknown error occured (-3237)" so if can help me please do.

  • Moving apps and music

    A quick question. My son is getting a 3GS. He as up to now been using my old (not activated) 1st gen iPhone as an iPod. So he's loaded it up with apps and music. I occasionally sync it to my laptop. Now when he gets his new phone, we'll start syncing

  • Path for putting the file while doing "Proxy to MDM " Scenario

    Hi , Please let me the path from which the MDM Server Picks the Files Thanks Srini

  • Managing contact groups in E71 and N97 mini

    It seems that the E71 does not support groups like older models used to: apparently groups are listed alongside contacts, and it is no longer possible to see and search groups directly. I'd like to see my groups straight away (e.g. clients, business

  • How to install acrobat professional 7 on windows 8

    I just purchased a new computer that runs windows 8.  I have acrobat professional 7 installed on my old computer, unfortunately I downloaded it directly from Adobe and didn't get a CD, I only have my product registration receipt with a serial number.