V$latch_children

Hello
in V$latch_children we have latch# as well as child#. Latch# is the parent latch of the child. Does it mean that latch# is the holder of the latch? And child# is waiting for latch?
Rgds

Hi,
Latch# is the latch number for parent latch and child# is the number for child latch. Child latch is not the one that is waiting for the latch. Parent latch have its child latches which further performs their task. To know little about child latches please go through the below link:-
http://learningoracle.wordpress.com/2008/02/19/latches-and-latch-contention/
To know about V$LATCH_CHILDREN go through the below link:-
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_1137.htm
Regards

Similar Messages

  • 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>

  • Unique Constraint error while executing statspack.snap procedure

    The following is the error which popped up when i was trying to execute statspack.snap procedure from perfstat user:
    ORA-00001: unique constraint (PERFSTAT.STATS$LATCH_CHILDREN_PK) violated
    ORA-06512: at "PERFSTAT.STATSPACK", line 1619
    ORA-06512: at "PERFSTAT.STATSPACK", line 71
    ORA-06512: at line 1
    How could i resolve such a problem, as all the constraints and objects for this user are created while running the oracle supplied script 'spcreate.sql'.
    If any 1 knows how to handle such a situation , can come forward n please help me out.

    SQL> execute statspack.snap (i_snap_level=>10);
    ERROR at line 1:
    ORA-00001: unique constraint (PERFSTAT.STATS$LATCH_CHILDREN_PK) violated
    ORA-06512: at "PERFSTAT.STATSPACK", line 1619
    ORA-06512: at "PERFSTAT.STATSPACK", line 71
    ORA-06512: at line 1
    Cause
    -- Its because of the bug # 2384758.
    "STATSPACK.SNAP GIVES ORA-1 ON STATS$LATCH_CHILDREN_PK WHEN I_SNAP_LEVEL=>10"
    -- The STATS$LATCH_CHILDREN table has a primary key constraint on (snap_id, dbid, instance_number, latch#, child#).
    Fix
    -- This is fixed in 9.0.2 and will not be backported to earlier versions because the level 10 is not a normal level to be setting unless requested by oracle support.

  • Please, do not read this thread. This is a test.

    1. X$KGLLK, X$KGLPN --> definition
    2. EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS(); job log--> where??
    ① You might see this Problem: Perf: Emd_maintenance.Execute_em_dbms_job_procs() Job Using All Cpu Doc ID: Note:308291.1.
    ② Oracle Metalink Doc ID 4636497 EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS() JOB DOES NOT STOP.
    Extracts of the Document,
    DBConsole is stopped the EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS() continues running each minute. This job must be stopped too because Agent is not collecting information because is down.
    ③ You can remove this as indicated in the Metalink Document that I have referenced in my first post. After that you can create this job manually by viewing How to create job EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS manually
    Doc ID Note: 44033.1. You can then see if the problem persists.
    Additionally you should perform these tasks at test sites and please read the documents carefully.
    3. DBSNMP/SYSMAN user
    4. dbconsole, emagent --> difference
    5. sysaux tablespace segment --> organize
    6. kill J001 on a test db and see what will happen
    7. emagent.trc のログ
    8. lock 関連テーブル整理
    - dba_ddl_locks or dba_lock_internal
    - v$lock and v$locked_object only shows enqueue locks, not library cache locks.
    9. 10g default procedureのtruncate command
    - enterprise manager のdefault procedureが、truncateを実行している。--> どれ??
    10. how about enabling trace event 10046 to see where your kernals are waiting?
    --> 10046 trace event for node2 444 session
    11. library cache invalidated object monitoring, reload monitoring
    12. v$latch (and v$latch_children)
    - v$libraryache latch get/pin
    13. AWR report
    - library cache 関連
    - parsing 関連
    - what is cpu time in Top 5 Timed Events
    --> I'd take a guess that you have a problem with excessive CPU usage causing a library cache problem as a side effect.
    -There are many notes in metalink, which will help you to identify root cause of "libary cache lock".
    14. parameter
    cursor_space_for_time=true,
    ●● その他
    If the problem still, persists, I suggest you to run hunganlyze ' DIAGNOSING DATABASE HANGING ISSUES' see metalink.

    1. X$KGLLK, X$KGLPN --> definition
    2. EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS(); job log--> where??
    ① You might see this Problem: Perf: Emd_maintenance.Execute_em_dbms_job_procs() Job Using All Cpu Doc ID: Note:308291.1.
    ② Oracle Metalink Doc ID 4636497 EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS() JOB DOES NOT STOP.
    Extracts of the Document,
    DBConsole is stopped the EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS() continues running each minute. This job must be stopped too because Agent is not collecting information because is down.
    ③ You can remove this as indicated in the Metalink Document that I have referenced in my first post. After that you can create this job manually by viewing How to create job EMD_MAINTENANCE.EXECUTE_EM_DBMS_JOB_PROCS manually
    Doc ID Note: 44033.1. You can then see if the problem persists.
    Additionally you should perform these tasks at test sites and please read the documents carefully.
    3. DBSNMP/SYSMAN user
    4. dbconsole, emagent --> difference
    5. sysaux tablespace segment --> organize
    6. kill J001 on a test db and see what will happen
    7. emagent.trc のログ
    8. lock 関連テーブル整理
    - dba_ddl_locks or dba_lock_internal
    - v$lock and v$locked_object only shows enqueue locks, not library cache locks.
    9. 10g default procedureのtruncate command
    - enterprise manager のdefault procedureが、truncateを実行している。--> どれ??
    10. how about enabling trace event 10046 to see where your kernals are waiting?
    --> 10046 trace event for node2 444 session
    11. library cache invalidated object monitoring, reload monitoring
    12. v$latch (and v$latch_children)
    - v$libraryache latch get/pin
    13. AWR report
    - library cache 関連
    - parsing 関連
    - what is cpu time in Top 5 Timed Events
    --> I'd take a guess that you have a problem with excessive CPU usage causing a library cache problem as a side effect.
    -There are many notes in metalink, which will help you to identify root cause of "libary cache lock".
    14. parameter
    cursor_space_for_time=true,
    ●● その他
    If the problem still, persists, I suggest you to run hunganlyze ' DIAGNOSING DATABASE HANGING ISSUES' see metalink.

  • Latch: row cache objects

    Hello everyone,
    Note: Apologize for the bad formatting, tried but it seems I forgot how to use it
    BANNER
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    I've seen  high "*latch: row cache objects*" in SP/ASH report for ~14 hours back, when the users were unable to connect to the database. There were,
    WARNING: inbound connection timed out (ORA-3136)
      Time: 30-APR-2012 02:24:36
      Tracing not turned on.
      Tns error struct:
    errors all over the alert log for the duration of 6 minutes of the problem.
    I've put few records in bold due to which I concluded that the problem was with "dc_users" thing.
    Can anybody tell me how/where I should proceed forward ?
    SP report:Instance Efficiency Indicators
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Buffer Nowait %: 100.00 Redo NoWait %: 100.00
    Buffer Hit %: 99.84 Optimal W/A Exec %: 100.00
    Library Hit %: 97.43 Soft Parse %: 87.86
    Execute to Parse %: 22.54 Latch Hit %: 99.95
    Parse CPU to Parse Elapsd %: 0.30 % Non-Parse CPU: 87.83
    Shared Pool Statistics Begin End
    Memory Usage %: 45.09 46.98
    % SQL with executions>1: 11.49 13.15
    % Memory for SQL w/exec>1: 72.96 21.33
    Top 5 Timed Events Avg %Total
    ~~~~~~~~~~~~~~~~~~ wait Call
    Event Waits Time (s) (ms) Time
    latch: row cache objects 6,655 634,260 95306 97.0
    log file sync 289,923 6,469 22 1.0
    CPU time 5,039 .8
    db file sequential read 310,084 2,840 9 .4
    log file parallel write 451,706 1,144 3 .2
    ASH Report
    Analysis Begin Time: 30-Apr-12 02:24:00
    Analysis End Time: 30-Apr-12 02:30:00
    Elapsed Time: 6.0 (mins)
    Begin Data Source: DBA_HIST_ACTIVE_SESS_HISTORY
    in AWR snapshot 12185
    End Data Source: DBA_HIST_ACTIVE_SESS_HISTORY
    in AWR snapshot 12185
    Sample Count: 1,385
    Average Active Sessions: 38.47
    Avg. Active Session per CPU: 1.60
    Report Target: None specified
    Top User Events DB/Inst: NIKU/niku (Apr 30 02:24 to 02:30)
    Avg Active
    Event Event Class % Event Sessions
    latch: row cache objects Concurrency 75.45 29.03
    CPU + Wait for CPU CPU 9.75 3.75
    log file sync Commit 3.83 1.47
    db file sequential read User I/O 3.61 1.39
    Top Event P1/P2/P3 Values DB/Inst: NIKU/niku (Apr 30 02:24 to 02:30)
    Event % Event P1 Value, P2 Value, P3 Value % Activity
    Parameter 1 Parameter 2 Parameter 3
    latch: row cache objects         75.60       "42287858200","279","0"      75.60
    address number tries
      1* select addr, latch#, child#, name, misses, gets from v$latch_children where name like '%row%cache%objec%'  order by gets , misses
    niku> /
    ADDR                 LATCH#     CHILD# NAME                                                   MISSES       GETS
    0000000A16FF21C8        279         26 row cache objects                                           0          0
    0000000A16FF14C8        279          2 row cache objects                                           0          0
    00000009D88D7ED8        279          3 row cache objects                                           0          0
    0000000A16FF1B48        279         14 row cache objects                                           0          0
    00000009D88D8558        279         15 row cache objects                                           0          0
    0000000A16FF1CE8        279         17 row cache objects                                           0          0
    0000000A26265A28        279         19 row cache objects                                           0          0
    0000000A16FF1E88        279         20 row cache objects                                           0          0
    00000009D88D8898        279         21 row cache objects                                           0          0
    0000000A26265BC8        279         22 row cache objects                                           0          0
    0000000A16FF2028        279         23 row cache objects                                           0          0
    00000009D88D8A38        279         24 row cache objects                                           0          0
    0000000A26265D68        279         25 row cache objects                                           0          0
    00000009D88D8BD8        279         27 row cache objects                                           0          0
    0000000A26265F08        279         28 row cache objects                                           0          0
    00000009D88D8D78        279         30 row cache objects                                           0          0
    0000000A262660A8        279         31 row cache objects                                           0          0
    0000000A16FF2508        279         32 row cache objects                                           0          0
    0000000A16FF26A8        279         35 row cache objects                                           0          0
    00000009D88D90B8        279         36 row cache objects                                           0          0
    0000000A262663E8        279         37 row cache objects                                           0          0
    0000000A262668C8        279         46 row cache objects                                           0          0
    0000000A26266A68        279         49 row cache objects                                           0          0
    0000000A16FF2368        279         29 row cache objects                                           0         11
    0000000A16FF2848        279         38 row cache objects                                           0        116
    0000000A16FF29E8        279         41 row cache objects                                           0        200
    00000009D88D93F8        279         42 row cache objects                                           0        318
    00000009D88D9258        279         39 row cache objects                                           0       1010
    0000000A16FF2EC8        279         50 row cache objects                                           0       1406
    00000009D88D9598        279         45 row cache objects                                           0       1472
    0000000A26266588        279         40 row cache objects                                           0       1705
    0000000A26266728        279         43 row cache objects                                           0       7383
    0000000A16FF2B88        279         44 row cache objects                                           0      32346
    00000009D88D98D8        279         51 row cache objects                                          19      63948
    0000000A26265888        279         16 row cache objects                                           0      88045
    0000000A26266248        279         34 row cache objects                                           0     141176
    00000009D88D9738        279         48 row cache objects                                           0     326672
    0000000A16FF19A8        279         11 row cache objects                                         867    1770385
    00000009D88D8078        279          6 row cache objects                                           9    1979542
    0000000A16FF2D28        279         47 row cache objects                                           2    3435018
    00000009D88D86F8        279         18 row cache objects                                        2557   14956121
    0000000A26265068        279          1 row cache objects                                         224   24335868
    0000000A262653A8        279          7 row cache objects                                       29760  133991553
    00000009D88D8F18        279         33 row cache objects                                       60612  677263122
    00000009D88D83B8        279         12 row cache objects                                       23981  739014460
    0000000A26265208        279          4 row cache objects                                    19973399  852043775
    0000000A26265548        279         10 row cache objects                                      280137  856097342
    00000009D88D8218        279          9 row cache objects                                   715879777 1219000976
    0000000A262656E8        279         13 row cache objects                                     3856073 2397402780
    0000000A16FF1668        279          5 row cache objects                                    12763217 2920278217
    *0000000A16FF1808        279          8 row cache objects                                    67329804 4145389092*
    51 rows selected.
    niku> list
      1 select addr, latch#, child#, name, misses, gets from v$latch_children where name like '%row%cache%objec%'  order by gets , misses
    niku> select distinct s.kqrstcln latch#,r.cache#,r.parameter name,r.type,r.subordinate#
    from v$rowcache r,x$kqrst s
    where r.cache#=s.kqrstcid
    order by 1,4,5;  2    3    4
        LATCH#     CACHE# NAME                                               TYPE        SUBORDINATE#
             1          3 dc_rollback_segments                               PARENT
             2          1 dc_free_extents                                    PARENT
             3          4 dc_used_extents                                    PARENT
             4          2 dc_segments                                        PARENT
             5          0 dc_tablespaces                                     PARENT
             6          5 dc_tablespace_quotas                               PARENT
             7          6 dc_files                                           PARENT
             *8         10 dc_users                                           PARENT*
             *8          7 dc_users                                           SUBORDINATE            0*
             *8          7 dc_users                                           SUBORDINATE            1*
             *8          7 dc_users                                           SUBORDINATE            2*
             9          8 dc_objects                                         PARENT
             9          8 dc_object_grants                                   SUBORDINATE            0
            10         17 dc_global_oids                                     PARENT
            11         12 dc_constraints                                     PARENT
            12         13 dc_sequences                                       PARENT
            13         16 dc_histogram_defs                                  PARENT
            13         16 dc_histogram_data                                  SUBORDINATE            0
            13         16 dc_histogram_data                                  SUBORDINATE            1
            14         54 dc_sql_prs_errors                                  PARENT
            15         32 kqlsubheap_object                                  PARENT
            16         19 dc_table_scns                                      PARENT
            16         19 dc_partition_scns                                  SUBORDINATE            0
            17         18 dc_outlines                                        PARENT
            18         14 dc_profiles                                        PARENT
            19         47 realm cache                                        PARENT
            19         47 realm auth                                         SUBORDINATE            0
            20         48 Command rule cache                                 PARENT
            21         49 Realm Object cache                                 PARENT
            21         49 Realm Subordinate Cache                            SUBORDINATE            0
            22         46 Rule Set Cache                                     PARENT
            23         34 extensible security user and rol                   PARENT
            24         35 extensible security principal pa                   PARENT
            25         37 extensible security UID to princ                   PARENT
            26         36 extensible security principal na                   PARENT
            27         33 extensible security principal ne                   PARENT
            28         38 XS security class privilege                        PARENT
            29         39 extensible security midtier cach                   PARENT
            30         43 AV row cache 1                                     PARENT
            31         44 AV row cache 2                                     PARENT
            32         45 AV row cache 3                                     PARENT
            33         15 global database name                               PARENT
            34         20 rule_info                                          PARENT
            35         21 rule_or_piece                                      PARENT
            35         21 rule_fast_operators                                SUBORDINATE            0
            36         23 dc_qmc_ldap_cache_entries                          PARENT
            37         52 qmc_app_cache_entries                              PARENT
            38         53 qmc_app_cache_entries                              PARENT
            39         27 qmtmrcin_cache_entries                             PARENT
            40         28 qmtmrctn_cache_entries                             PARENT
            41         29 qmtmrcip_cache_entries                             PARENT
            42         30 qmtmrctp_cache_entries                             PARENT
            43         31 qmtmrciq_cache_entries                             PARENT
            44         26 qmtmrctq_cache_entries                             PARENT
            45          9 qmrc_cache_entries                                 PARENT
            46         50 qmemod_cache_entries                               PARENT
            47         24 outstanding_alerts                                 PARENT
            48         22 dc_awr_control                                     PARENT
            49         25 SMO rowcache                                       PARENT
            50         40 sch_lj_objs                                        PARENT
            51         41 sch_lj_oids                                        PARENT
    61 rows selected.
    niku> select parameter, gets from v$rowcache order by gets desc;
    PARAMETER                              GETS
    dc_users                         2802019571
    dc_tablespaces                   2405092307
    dc_objects                       1815427326                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    jjk wrote:
    I've already been thru the link that you've mentioned and unfortunately couldn't make much use of it.I didn't think it was really likely to be relevant, but there was always a long shot that it might have given you a clue.
    Considering the "dc_users" had maximum gets, I thought (rather as per internet) that it might be the point of contention. However I did observe high misses on child# 9 which is "dc_objects". It's often the case that the misses is more important than the gets when you see lots of gets and misses on a few latches/caches - the bit that might have been most instructure was the dictionary cache bit from the AWR showing gets, misses, scans, scanmisses etc. It might have told us a little about what was going in and out of the dictionary cache and let us guess why.
    In alert log:
    Sun Apr 29 02:20:00 2012
    29-APR-2012 02:20:00 -- xxxxxxx package - REGRANT_READONLY Begin re-grant read only roles
    Sun Apr 29 02:24:34 2012
    29-APR-2012 02:24:34 -- xxxxxxx package - REGRANT_READONLY End re-grant read only roles
    Sun Apr 29 02:30:00 2012
    29-APR-2012 02:30:00 -- xxxxxxx package - REGRANT_READWRITE Begin re-grant read write roles
    Sun Apr 29 02:32:02 2012
    29-APR-2012 02:32:02 -- xxxxxxx package - REGRANT_READWRITE End re-grant read write roles
    Is this code that "regrants" roles to users who already have them ? That's what it sounds like, and that sounds like something that would impact on various parts of the dictionary cache, especially dc_users, and possibly dc_obejcts.
    CPU per    Elap per     Old
    Executions   Rows Processed   Rows per Exec    Exec (s)   Exec (s)  Hash Value
    161,198           1,244              0.0       0.00        0.00   978935325
    select /*+ rule */ c.name, u.name from con$ c, cdef$ cd, user$ u
    where c.con# = cd.con# and cd.enabled = :1 and c.owner# = u.us
    er#
    159,955         159,952              1.0       0.00        0.00  2458412332
    select o.name, u.name from obj$ o, user$ u  where o.obj# = :1 an
    d o.owner# = u.user#
    159,932               6              0.0       0.00        0.00  2636710067
    insert into objauth$(option$,grantor#,obj#,privilege#,grantee#,c
    ol#,sequence#) values(decode(:1,0,null,:1),:2,:3,:4,:5,decode(:6
    ,0,null,:6),object_grant.nextval)
    147,168         147,168              1.0       0.00        0.00  3468666020
    select text from view$ where rowid=:1
    124,635         124,635              1.0       0.00        0.00   564166580
    select count(*) from (                                 select u.
    name                                        from registry$ r, us
    er$ u                            where r.status in (1,3,5)
    and r.namespace = 'SERVER'The first one looks like a response to a constraint being breached.
    The third one looks like something that might happen when you grant a privilege on an object to a user - and maybe the first one happens if the user has already got it and the insert raises a "duplicate key" error. The fourth one commonly happens when you have to re-optimize a query containing a view - and when you execute DDL (such as changing privileges on an object) you invalidate SQL and have to re-optimize it eventually. I can't remember where I've seen the second one appearing.
    If you have a process that tries to do a lot of grants on objects to users and roles in a very short time, it's quite likely to create havoc in the dictionary cache - check what that package was up to and why it runs.
    What is the missing information ?When I looked at some of your posting, the output didn't match the query, some of the later columns had gone missing - this might have been my browser rather than your input though.
    Regards
    Jonathan Lewis

  • Release the space from Tools tablespace

    Hi,
    I have found that TOOLS tablespace is 99%.
    The tools tablespace is typically used for collecting database statistics – not part of the application. These include Quest and Perfstat. How can I check at the objects in the tools tablespace to see what has grown and then determine if we need to purge data and reorg the objects.
    The mount point for this database is only 8 gig and is 84% used so we should not add “overhead” space unless absolutely necessary. The tools tablespace is already large for the size of the rest of the database.
    /dev/orabwelv 8388608 7011424 1377184 84% /ORACLE/BWEBPRD
    These are the contents in the tablespace
    OWNER TABLE_NAME OBJECT_TYPE TABLESPACE_NAME
    ORACLE PLAN_TABLE TABLE TOOLS
    ORACLE_APP STPL_DBAPRVS_PENDINGL TABLE TOOLS
    ORACLE_APP STPL_DBAPRVS_ACTIVITY_LOGL TABLE TOOLS
    ORACLE T_WEBBPRD TABLE TOOLS
    POSTD PLAN_TABLE TABLE TOOLS
    MONITORER TABLESPACE_GROWTH TABLE TOOLS
    MONITORER SEGMENT_GROWTH TABLE TOOLS
    OWNER TABLE_NAME OBJECT_TYPE TABLESPACE_NAME
    PERFSTAT STATS$PGA_TARGET_ADVICE TABLE TOOLS
    PERFSTAT STATS$SQL_WORKAREA_HISTOGRAM TABLE TOOLS
    PERFSTAT STATS$SHARED_POOL_ADVICE TABLE TOOLS
    PERFSTAT STATS$STATSPACK_PARAMETER TABLE TOOLS
    PERFSTAT STATS$INSTANCE_RECOVERY TABLE TOOLS
    PERFSTAT STATS$PARAMETER TABLE TOOLS
    PERFSTAT STATS$IDLE_EVENT TABLE TOOLS
    PERFSTAT STATS$PGASTAT TABLE TOOLS
    PERFSTAT STATS$SEG_STAT_OBJ TABLE TOOLS
    PERFSTAT STATS$SEG_STAT TABLE TOOLS
    PERFSTAT STATS$SQL_PLAN TABLE TOOLS
    OWNER TABLE_NAME OBJECT_TYPE TABLESPACE_NAME
    PERFSTAT STATS$SQL_PLAN_USAGE TABLE TOOLS
    PERFSTAT STATS$UNDOSTAT TABLE TOOLS
    PERFSTAT STATS$DLM_MISC TABLE TOOLS
    PERFSTAT STATS$RESOURCE_LIMIT TABLE TOOLS
    PERFSTAT STATS$SQL_STATISTICS TABLE TOOLS
    PERFSTAT STATS$SQLTEXT TABLE TOOLS
    PERFSTAT STATS$SQL_SUMMARY TABLE TOOLS
    PERFSTAT STATS$ENQUEUE_STAT TABLE TOOLS
    PERFSTAT STATS$WAITSTAT TABLE TOOLS
    PERFSTAT STATS$BG_EVENT_SUMMARY TABLE TOOLS
    PERFSTAT STATS$SESSION_EVENT TABLE TOOLS
    OWNER TABLE_NAME OBJECT_TYPE TABLESPACE_NAME
    PERFSTAT STATS$SYSTEM_EVENT TABLE TOOLS
    PERFSTAT STATS$SESSTAT TABLE TOOLS
    PERFSTAT STATS$SYSSTAT TABLE TOOLS
    PERFSTAT STATS$SGASTAT TABLE TOOLS
    PERFSTAT STATS$SGA TABLE TOOLS
    PERFSTAT STATS$ROWCACHE_SUMMARY TABLE TOOLS
    PERFSTAT STATS$ROLLSTAT TABLE TOOLS
    PERFSTAT STATS$BUFFER_POOL_STATISTICS TABLE TOOLS
    PERFSTAT STATS$LIBRARYCACHE TABLE TOOLS
    PERFSTAT STATS$LATCH_MISSES_SUMMARY TABLE TOOLS
    PERFSTAT STATS$LATCH_PARENT TABLE TOOLS
    OWNER TABLE_NAME OBJECT_TYPE TABLESPACE_NAME
    PERFSTAT STATS$LATCH_CHILDREN TABLE TOOLS
    PERFSTAT STATS$LATCH TABLE TOOLS
    PERFSTAT STATS$TEMPSTATXS TABLE TOOLS
    PERFSTAT STATS$FILESTATXS TABLE TOOLS
    PERFSTAT STATS$DB_CACHE_ADVICE TABLE TOOLS
    PERFSTAT STATS$SNAPSHOT TABLE TOOLS
    PERFSTAT STATS$LEVEL_DESCRIPTION TABLE TOOLS
    PERFSTAT STATS$DATABASE_INSTANCE TABLE TOOLS
    Please Suggest
    Message was edited by:
    user592074

    Thanks Chandra!
    Request you to kindly suggest me how to release the sapce from tool table. Database version is 9.2.0.6 (64 bi Please find the output below.
    SEGMENT_NAME SIZE_MB
    PLAN_TABLE .125
    SEGMENT_GROWTH 25
    STATS$BG_EVENT_SUMMARY 2
    STATS$BG_EVENT_SUMMARY_PK 2
    STATS$BUFFER_POOL_STATISTICS 1
    STATS$BUFFER_POOL_STATS_PK 1
    STATS$DATABASE_INSTANCE 1
    STATS$DATABASE_INSTANCE_PK 1
    STATS$DB_CACHE_ADVICE 2
    STATS$DB_CACHE_ADVICE_PK 1
    STATS$DLM_MISC 1
    STATS$DLM_MISC_PK 1
    STATS$ENQUEUE_STAT 2
    STATS$ENQUEUE_STAT_PK 2
    STATS$FILESTATXS 3
    STATS$FILESTATXS_PK 3
    STATS$IDLE_EVENT .125
    STATS$IDLE_EVENT_PK .125
    STATS$INSTANCE_RECOVERY 1
    STATS$INSTANCE_RECOVERY_PK 1
    STATS$LATCH 25
    STATS$LATCH_CHILDREN 1
    STATS$LATCH_CHILDREN_PK 1
    STATS$LATCH_MISSES_SUMMARY 1
    STATS$LATCH_MISSES_SUMMARY_PK 1
    STATS$LATCH_PARENT 1
    STATS$LATCH_PARENT_PK 1
    STATS$LATCH_PK 22
    STATS$LEVEL_DESCRIPTION .125
    STATS$LEVEL_DESCRIPTION_PK .125
    STATS$LIBRARYCACHE 1
    STATS$LIBRARYCACHE_PK 1
    STATS$PARAMETER 21
    STATS$PARAMETER_PK 24
    STATS$PGASTAT 1
    STATS$PGA_TARGET_ADVICE 1
    STATS$PGA_TARGET_ADVICE_PK 1
    STATS$RESOURCE_LIMIT 1
    STATS$RESOURCE_LIMIT_PK 1
    STATS$ROLLSTAT 2
    STATS$ROLLSTAT_PK 1
    STATS$ROWCACHE_SUMMARY 3
    STATS$ROWCACHE_SUMMARY_PK 3
    STATS$SEG_STAT 3
    STATS$SEG_STAT_OBJ 1
    STATS$SEG_STAT_OBJ_PK 1
    STATS$SEG_STAT_PK 1
    STATS$SESSION_EVENT 1
    STATS$SESSION_EVENT_PK 1
    STATS$SESSTAT 1
    STATS$SESSTAT_PK 1
    STATS$SGA 1
    STATS$SGASTAT 3
    STATS$SGASTAT_U 5
    STATS$SGA_PK 1
    STATS$SHARED_POOL_ADVICE 1
    STATS$SHARED_POOL_ADVICE_PK 1
    STATS$SNAPSHOT 1
    STATS$SNAPSHOT_PK 1
    STATS$SQLTEXT 5
    STATS$SQLTEXT_PK 1
    STATS$SQL_PGASTAT_PK 1
    STATS$SQL_PLAN 5
    STATS$SQL_PLAN_PK 1
    STATS$SQL_PLAN_USAGE 5
    STATS$SQL_PLAN_USAGE_HV 1
    STATS$SQL_PLAN_USAGE_PK 1
    STATS$SQL_STATISTICS 1
    STATS$SQL_STATISTICS_PK 1
    STATS$SQL_SUMMARY 17
    STATS$SQL_SUMMARY_PK 8
    STATS$SQL_WORKAREA_HISTOGRAM 1
    STATS$SQL_WORKAREA_HIST_PK 1
    STATS$STATSPACK_PARAMETER .125
    STATS$STATSPACK_PARAMETER_PK .125
    STATS$SYSSTAT 21
    STATS$SYSSTAT_PK 25
    STATS$SYSTEM_EVENT 3
    STATS$SYSTEM_EVENT_PK 4
    STATS$TEMPSTATXS 1
    STATS$TEMPSTATXS_PK 1
    STATS$UNDOSTAT 1
    STATS$UNDOSTAT_PK 1
    STATS$WAITSTAT 1
    STATS$WAITSTAT_PK 2
    STPL_DBAPRVS_ACTIVITY_LOG .0625
    STPL_DBAPRVS_PENDING .0625
    STPL_DBAPRVS_PENDING_PK .0625
    TABLESPACE_GROWTH .3125
    T_WEBBPRD .0625
    90 rows selected.
    Message was edited by:
    user592074

  • BUFFER CACHE 내의 HOT BLOCK을 찾기

    제품 : ORACLE SERVER
    작성날짜 : 2004-10-13
    BUFFER CACHE 내의 HOT BLOCK을 찾기
    =============================
    PURPOSE
    ORACLE은 data block을 효율적으로 관리하기 위하여 buffer cache를
    사용하고 있다.
    이 buffer cache는 각각 buffer handle을 가지고 있으며 buffer cache
    chain에 의하여 관리가 되고 있다. oracle은 원하는 block을 빨리 찾기
    위하여 block의 주소를 hash key로 사용하는 hash function을 사용하여
    특정 buffer chain을 찾고 이 list를 scan하여 원하는 block을 찾게
    된다. 따라서 특정 block은 하나의 buffer chain에 의하여 관리된다.
    이 buffer cache chains latch cocntention은 주로 이 buffer chain에
    의하여 관리되는 buffer수가 많거나 hot block(hot buffer)에 의한 경우로
    나누어 볼 수 있다.
    아래에서는 hot block을 찾는 방법에 대하여 설명하고 있다.
    Explanation
    1. v$latch_children에서 contention이 많은 buffer cache chain
    latch들을 찾는다.
    select * from
    (select l.child#, l.addr, l.sleeps, l.sleep1, l.sleep3
    from
    v$latch_children l
    where l.latch#= 66
    order by l.sleeps desc
    where rownum < 11
    이 쿼리를 일정한 간격을 두고 수행하여 현 시점에서 sleeps이 많은
    latch를 선별한다.
    CHILD# ADDR SLEEPS SLEEP1 SLEEP3
    29406 33F84420 301809 242441 4041
    2532 33BEDB68 233945 213363 651
    3642 33C13A70 215950 181390 2330
    3575 33C115CC 198600 102161 14556
    25216 33EF50B8 195763 176779 796
    33288 34008F18 180123 155168 1735
    18475 33E0EA3C 169387 156205 405
    32301 33FE7354 152855 137046 616
    20770 33E5D150 91845 74889 889
    2533 33BEDBF4 78774 74539 110
    10 rows selected.
    CHILD# ADDR SLEEPS SLEEP1 SLEEP3
    29406 33F84420 301809 242441 4041 *
    2532 33BEDB68 234272 213670 651
    3642 33C13A70 216086 181520 2330
    3575 33C115CC 198600 102161 14556 *
    25216 33EF50B8 196068 177069 797
    33288 34008F18 180123 155168 1735 *
    18475 33E0EA3C 169598 156408 405
    32301 33FE7354 152855 137046 616 *
    20770 33E5D150 91845 74889 889 *
    2533 33BEDBF4 78855 74618 110
    10 rows selected.
    현 시점에서 높은 sleeps 변화를 보이는 latch#은 2532, 3642,
    25216, 18475, 2533 latch들이다.
    2. 이제 이들 latch들로 관리되고 있는 buffer들 중에서 hot block들을
    찾는다.
    select b.hladdr, l.sleeps, l.sleep3, b.tch,
    b.dbarfil, b.dbablk, b.state
    from x$bh b, v$latch_children l
    where l.child#
    in
    (2532, 3642, 25216, 18475, 2533)
    and b.hladdr= l.addr
    order by tch
    x$bh의 tch는 touch count를 의미하므로 이 값이 가장 큰
    것부터 hot block들이라고 볼 수 있다.
    HLADDR SLEEPS SLEEP3 TCH DBARFIL DBABLK
    STATE
    33E0EA3C 169818 405 0 192
    102764 1
    33E0EA3C 169818 405 0 70
    97847 1
    33E0EA3C 169818 405 0 106
    38012 1
    33EF50B8 196361 797 1 193
    115327 1
    33C13A70 216224 2330 91 33
    4494 1
    33BEDBF4 78952 110 104 33
    3385 1
    33BEDB68 234617 651 132 33
    3384 1
    33EF50B8 196361 797 146 24
    25614 1
    33E0EA3C 169818 405 164 32
    10107 1
    3. 아래의 쿼리를 수행하여 hot block과 관련된 object를 찾는다.
    select segment_name , segment_type , owner
    from sys.dba_extents
    where file_id = 32
    and 10107 between block_id and (block_id+(blocks-1))
    SEGMENT_NAME SEGMENT_TYPE OWNER
    FRED_TABLE TABLE MARY
    4. hot block이 확인된 object의 header block인지 확인해 본다.
    select header_file, header_block, freelist_groups, freelists
    from dba_segments where
    segment_name = 'FRED_TABLE'
    and owner = 'MARY'
    HEADER_FILE HEADER_BLOCK FREELIST_GROUPS FREELISTS
    32 4769 4 4
    해당 block(10107)이 segment header block ~ segment header
    block(4769) + free list group(4) 사이에 들어가지 않으므로
    data block이다.
    Example
    none
    Reference Documents
    none

  • Latch: cache buffers chains

    Hi,
    I am facing the following in my DB.Oracle version is 11.1.0.7.0
    Event Waits Time(s) Avg wait (ms) % DB time Wait Class
    latch: cache buffers chains 37,910,465 17,344 0 42.64 Concurrency
    I checked the SQL causing the wait using following query.
    select count(*), SQL_ID from gv$active_session_history where event like '%cache buffers%' group by SQL_ID;
    COUNT(*) SQL_ID
    1
    3 3wunvbmu64d8j
    2 9q2ux8f92za7m
    36000 47g8dw48ghk5s
    2 5arqxftxr7tjr
    Also i tried the following.
    select count(*) child_count, sum(gets) sum_gets, sum(misses) sum_misses, sum(sleeps) sum_sleeps from v$latch_children where name = 'cache buffers chains';
    CHILD_COUNT SUM_GETS SUM_MISSES SUM_SLEEPS
    65536 1.5723E+10 3163139088 56744600
    SQL> select P1 from v$session_wait where event = 'cache buffer chains';
    no rows selected
    How do i proceed with this?
    SQL ID - 47g8dw48ghk5s is an update query.Can increasing freelists of this table help ??Kindly assist me.
    Thanks.

    user10698496 wrote:
    Elapsed Time (s) CPU Time (s) Executions  Elap per Exec (s)  % Total DB Time SQL Id        SQL               Module SQL Text
    29,725        6,747     82,289               0.36            73.08 47g8dw48ghk5s app2 (TNS V1-V3)  UPDATE ZH_TBL SE
    CPU Time (s) Elapsed Time (s) Executions  CPU per Exec (s) % Total % Total DB Time SQL Id        SQL               Module SQL Text
    6,747           29,725     82,289              0.08   62.52           73.08 47g8dw48ghk5s app2 (TNS V1-V3)  UPDATE ZH_TBL SE...
    Assuming that this is the standard one-hour snapshot that seems to be a rather small number of executions to waste so much latch time.
    Moreover, since it's an update by rowid it's surprising that it should take so much CPU per executions unless you have a very large number of indexes on the table which have to be maintained.
    Can you show us the "Load profile" and "Top 5 timed events" from the same period, plus the system summary bit (memory, cache size, CPU count) that's near the top of the report.
    In your position I'd run up a little query to look at the stats in v$sql for that sql_id, and watch the executions, buffer_gets, cpu_time etc. changing over a few minutes in case there's something funny with the snapshot and youre losing large numbers in the execution counts. (I'd be particularly interested in the number of CPUs you have, and the CPU load on the system - sometimes you can get really wierd latching issue which are basically caused by CPU loading, especially on NUMA systems).
    Since you've got the ASH data, there's also more information you can get from there - is it
    a) the same latch all the time
    b) a small number of different latches
    c) a small number of different latches, but the same latch for any specific sid/serial
    d) does the latch seem to change over time
    If it's a small number of fixed latches you may be able to query the buffer cache with the latch address to see if there are any "obvious" blocks with a high touch count covered by those latches - they may be things like the root blocks of indexes used for referential integrity.
    If the latch seems to keep moving it could be an indication that the update is slowly travelling along a table and every block is subject to competition from a number of concurrent processes.
    Kyle Hailey has some sample queries against ASH that may point you in the right direction: http://sites.google.com/site/embtdbo/wait-event-documentation/oracle-latch-cache-buffers-chains
    If you can spot a session hitting the problem you could also start tracing it to see if that level of detail gives you more clues, and I'd also start thinking about read up Tanel's notes.
    Regards
    Jonathan Lewis
    To post code, statspack/AWR report, execution plans or trace files, START and END the text with the tag {noformat}{noformat} (the word "code" in lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Shared Pool utilisation

    Hello Team:
    I ran a metalink script to report the shared pool utilization recently. I took this output when the database was on peak load.
    SQL> /
    Obj mem: 66435759 bytes (63.36MB)
    Shared sql: 324219036 bytes (309.2MB)
    Cursors: 341207073 bytes (325.4MB)
    Free memory: 67228508 bytes (64.11MB)
    Shared pool utilization (total): 468785754 bytes (447.07MB)
    Shared pool allocation (actual): 754974720bytes (720MB)
    Percentage Utilized: 91%
    does this mean I have to add more space to shared pool. If so what is the threshold value?
    Regards,
    Bala

    Bhawani nandan Prasad - Principal DBA -- See a to z diagnostics about Shared pool
    1. Memory     2
    a. Shared Pool     2
    1. Introduction     2
    2. Architecture     2
    3. Scripts for different DBA tasks:     5
    a.Measure object usage inside the shared pool and Tune shared pool     7
    b.Check reload problem in library cache     12
    c.Find the large queries in the shared pool library cache (using > 4mb each)     13
    d.Find objects that can be considered pining into the shared pool     13
    e.LRU work and objects were loaded and flushed     13
    f.How much are waiting for Library Cache Latch     14
    g.Queries identical but aren’t shared.     14
    h.Get Biggest chunk of free memory.     14
    i.Check the shared pool reserved size status     16
    j.When having multiple subheaps:     16
    k.Check shared pool at first glance quick diagnostics     17
    l.Memory Usage - object list level view     17
    m.Loads Number of times object has been loaded     17
    n.Check number of times and object has been executed     18
    o.Check shared pool in more details     18
    p.Library Cache Statistics     18
    q.Reserve Pool Settings     19
    r.Pinned Objects     19
    s.Finding literal SQL     19
    t.Finding the Library Cache hit ratio     19
    u. Row Cache Misses – Dictionary cache stats     19
    v. Checking hash chain lengths     20
    w. Checking for high version counts     20
    x. Finding statement/s which use lots of shared pool memory     20
    y. Allocations causing shared pool memory to be 'aged' out     21
    z. Issues in various Oracle Releases     21
    4. Terminology     22
    5. Oracle 11g Caching and Pooling – SQL Result Cache     27
    6. References     37
    2. SQL     38
    3. Statistics     38
    4. Wait events     38
    5. Schema     39
    6. General     39
    a. Scripts     39
    1. accept.sql     39
    1. Memory
    a. Shared Pool
    1. Introduction
    Shared pool is used to cache different types of data such as textual and executable forms of PL/SQL blocks and SQL statements, dictionary cache data, and other data in SGA. Additional shared memory needed in the SHARED POOL if using ASM storage. Gathering schema/database stats (table/index stats) makes database query performance better and it reduce utilization of shared pool. Hence, practice to schedule job to gather stats regularly which suites your database performance. If you use shared pool effectively you can reduce resource consumption in at least four ways
    1.     Parse overhead is avoided if the SQL statement is already in the shared pool. This saves CPU resources on the host and elapsed time for the end user.
    2.     Latching resource usage is significantly reduced, which results in greater scalability.
    3.     Shared pool memory requirements are reduced, because all applications use the same pool of SQL statements and dictionary resources.
    4.     I/O resources are saved, because dictionary elements that are in the shared pool do not require disk access.
    This sharable area of memory is managed as a sophisticated cache and heap manager rolled into one. It has 3 fundamental problems to overcome:
    1.     The unit of memory allocation is not a constant - memory allocations from the pool can be anything from a few bytes to many kilobytes
    2.     Not all memory can be 'freed' when a user finishes with it (as is the case in a traditional heap manager) as the aim of the shared pool is to maximize share of information. The information in the memory may be useful to another session - Oracle cannot know in advance if the items will be of any use to anyone else or not.
    3.     There is no disk area to page out to so this is not like a traditional cache where there is a file backing store. Only "rewriteable" information can be discarded from the cache and it has to be re-created when it is next needed.
    Oracle 10g architecture of Shared pool:
    Library Cache     Shared SQL Area (Hash Value, SQL source, Execution plan)
    Data Dictionary Cache
    Enqueues     Fixed Area     Other
    Latches          
    Oracle 11g architecture of Shared pool:
    Library Cache     Shared SQL Area (Hash Value, SQL source, Execution plan)
    Data Dictionary Cache
    Result Cache
    Enqueues     Fixed Area     Other
    Latches          
    1. Library Cache
    Shared Sql Area: contains Parsed SQL and execution Plans for statements already run against the database. This area allows SQL execution plans to be reused by many users.
    Private SQL Area: Private SQL areas are non-shared memory areas assigned to unique user sessions.
    Pl/sql Area: contains the recently executed Procedures, Functions and Packages.
    Control Structures: Common control structure information example Memory for Latches and locks, sequence cache.
    2. Dictionary cache known as the row cache.
    Dictionary cache stores all the metadata info of tables and views in the database, Names and data types of the columns in the database, Object and system privileges of all the Users. Oracle maintains the stats of all the objects in the shared pool, if any of the memory objects are not used from the last 3 seconds, these memory objects will be aged out and will be removed from the cache. All the Shared Pool Structures are maintained by a LRU (least recently Used) algorithm, by which Oracle removes the objects from the shared Pool, until there is enough free space in the shared Pool to keep new Object.
    3. Scripts for different DBA tasks:
    Dictionary Views for shared POOL:
    NON-RAC
    V$DB_CACHE_ADVICE
    V$DB_OBJECT_CACHE
    V$DLM_LATCH
    V$DLM_LOCKS
    V$LATCH
    V$LATCHHOLDER
    V$LATCHNAME
    V$LATCH_CHILDREN
    V$LATCH_MISSES
    V$LATCH_PARENT
    V$LIBRARYCACHE
    V$LOCK
    V$LOCKED_OBJECT
    V$LOCKS_WITH_COLLISIONS
    V$LOCK_ACTIVITY
    V$LOCK_ELEMENT
    V$OPEN_CURSOR
    V$PROCESS
    V$PX_PROCESS
    V$PX_PROCESS_SYSSTAT
    V$PX_SESSION
    V$PX_SESSTAT
    V$ROWCACHE
    V$ROWCACHE_PARENT
    V$ROWCACHE_SUBORDINATE
    V$SESSION
    V$SESSION_CONNECT_INFO
    V$SESSION_CURSOR_CACHE
    V$SESSION_EVENT
    V$SESSION_LONGOPS
    V$SESSION_OBJECT_CACHE
    V$SESSION_WAIT
    V$SESSTAT
    V$SESS_IO
    V$SGA
    V$SGASTAT
    V$SGAINFO
    V$SGA_DYAMIC_COMPONENTS
    V$SGA_DYNAMIC_FREE_MEMORY
    V$SGA_RESIZE_OPS
    V$SGA_CURRENT_RESIZE_OPS
    v$shared_pool_advice
    V_$SHARED_POOL_ADVICE
    V$SHARED_POOL_RESERVED
    V$SHARED_SERVER
    V$SORT_SEGMENT
    V$SORT_USAGE
    V$SQL
    V$SQLAREA
    V$SQLTEXT
    V$SQLTEXT_WITH_NEWLINES
    V$SQL_BIND_DATA
    V$SQL_BIND_METADATA
    V$SQL_CURSOR
    V$SQL_SHARED_CURSOR
    V$SQL_SHARED_MEMORY
    V$STATNAME
    V$SUBCACHE
    V$SYSSTAT
    V$SYSTEM_CURSOR_CACHE
    V$SYSTEM_EVENT
    V$SYSTEM_PARAMETER
    X$KSMSP
    RAC
    GV$LATCH
    GV$LATCHHOLDER
    GV$LATCHNAME
    GV$LATCH_CHILDREN
    GV$LATCH_MISSES
    GV$LATCH_PARENT
    GV$LIBRARYCACHE
    GV$LOCK
    GV$LOCKED_OBJECT
    GV$LOCKS_WITH_COLLISIONS
    GV$LOCK_ACTIVITY
    GV$LOCK_ELEMENT
    GV$PROCESS
    GV$PX_PROCESS
    GV$PX_PROCESS_SYSSTAT
    GV$PX_SESSION
    GV$PX_SESSTAT
    GV$ROWCACHE
    GV$ROWCACHE_PARENT
    GV$ROWCACHE_SUBORDINATE
    GV$SESSION
    GV$SESSION_CONNECT_INFO
    GV$SESSION_CURSOR_CACHE
    GV$SESSION_EVENT
    GV$SESSION_LONGOPS
    GV$SESSION_OBJECT_CACHE
    GV$SESSION_WAIT
    GV$SESSTAT
    GV$SESS_IO
    GV$SGA
    GV$SGASTAT
    gv$shared_pool_advice
    GV$SHARED_POOL_RESERVED
    GV$SHARED_SERVER
    GV$SORT_SEGMENT
    GV$SORT_USAGE
    GV$SQL
    GV$SQLAREA
    GV$SQLTEXT
    GV$SQLTEXT_WITH_NEWLINES
    GV$SQL_BIND_DATA
    GV$SQL_BIND_METADATA
    GV$SQL_CURSOR
    GV$SQL_SHARED_CURSOR
    GV$SQL_SHARED_MEMORY
    GV$STATNAME
    GV$SUBCACHE
    GV$SYSSTAT
    GV$SYSTEM_CURSOR_CACHE
    GV$SYSTEM_EVENT
    GV$SYSTEM_PARAMETER
    GV$WAITSTAT
    GV$_LOCK
    a.Measure object usage inside the shared pool and Tune shared pool
    set pagesize 132
    column owner format a16
    column name format a36
    column sharable_mem format 999,999,999
    column executions format 999,999,999
    prompt
    prompt Memory Usage of Shared Pool Order - Biggest First
    prompt
    column name format 45
    select owner, name||' - '||type name, sharable_mem from v$db_object_cache
    where sharable_mem > 10000
    and type in ('PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'PROCEDURE')
    order by sharable_mem desc
    prompt
    prompt Loads into Shared Pool - Most Loads First
    prompt
    select owner, name||' - '||type name, loads , sharable_mem from v$db_object_cache
    where loads > 3
    and type in ('PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'PROCEDURE')
    order by loads desc
    prompt
    prompt Executions of Objects in the Shared Pool - Most Executions First
    prompt
    select owner, name||' - '||type name, executions from v$db_object_cache
    where executions > 100
    and type in ('PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'PROCEDURE')
    order by executions desc
    select 'If the values for the EXEC and LOADS close increase SHARED_POOL_SIZE!' from dual ;
    set feedback off
    set linesize 80
    set pagesize 52
    clear columns
    clear breaks
    col executions HEADING EXEC
    col sharable_mem heading SHAMEM
    col owner format a8
    col name format a30
    col type format a12
    set numwidth 8
    ttitle center 'Data Base Objects Owned by All Users Statistics' skip 2
    select name, type, sharable_mem, loads, executions, pins
    from sys.v_$db_object_cache ;
    b.Check reload problem in library cache
    select namespace, pins, reloads from v$librarycache;
    show parameters shared_pool
    select bytes/1024/1024 from v$sgastat where pool='shared pool' and name='free memory';
    c.Find the large queries in the shared pool library cache (using > 4mb each)
    SELECT sql_text "Stmt", count(*), sum(sharable_mem) "Mem",
    sum(users_opening) "Open", sum(executions) "Exec"
    FROM v$sql GROUP BY sql_text HAVING sum(sharable_mem) > 4096000;
    d.Find objects that can be considered pining into the shared pool
    column name format a40
    column owner format a15
    select owner, name, executions, locks, pins, loads, kept from v$db_object_cache where loads > 10;
    create temp table and insert records of candidates to be pinned.
    CREATE TABLE LRU_TMP AS SELECT * FROM X$KSMLRU;
    INSERT INTO LRU_TMP SELECT * FROM X$KSMLRU;
    Use the LRU_TMP table for analysis.
    SELECT USERNAME, KSMLRCOM, KSMLRHON, KSMLRNUM, KSMLRSIZ, SQL_TEXT
    FROM V$SQLAREA A, LRU_TMP K, V$SESSION S WHERE KSMLRSIZ > 3000
    AND A.ADDRESS=S.SQL_ADDRESS AND A.HASH_VALUE = S.SQL_HASH_VALUE
    AND SADDR=KSMLRSES;
    You can see the candidates to pin from the query below
    COL STORED_OBJECT FORMAT A40;
    COL SQ_EXECUTIONS FORMAT 999,999;
    SELECT /*+ ORDERED USE_HASH(D) USE_HASH(C) */ O.KGLNAOWN||’.'||O.KGLNAOBJ STORED_OBJECT, SUM(C.KGLHDEXC) SQL_EXECUTIONS
    FROM SYS.X$KGLOB O, SYS.X$KGLRD D, SYS.X$KGLCURSOR C
    WHERE
    O.INST_ID = USERENV(’INSTANCE’) AND
    D.INST_ID = USERENV(’INSTANCE’) AND
    C.INST_ID = USERENV(’INSTANCE’) AND
    O.KGLOBTYP IN (7, 8, 9, 11, 12) AND
    D.KGLHDCDR = O.KGLHDADR AND
    C.KGLHDPAR = D.KGLRDHDL
    GROUP BY O.KGLNAOWN, O.KGLNAOBJ
    HAVING SUM(C.KGLHDEXC) > 0
    ORDER BY 2 DESC;
    How to pin object
    EXECUTE SYS.DBMS_SHARED_POOL.SIZES(150);
    EXECUTE SYS.DBMS_SHARED_POOL.KEEP('SYS.STANDARD');
    EXECUTE SYS.DBMS_SHARED_POOL.UNKEEP('SYS.STANDARD');
    e.LRU work and objects were loaded and flushed
    LRU work in the shared pool KSMLRNUM stores the number of objects that were flushed to load the large object. KSMLRISZ stores the size of the object that was loaded (contiguous memory allocated)
    column ksmlrcom format a20
    column username format a5
    select username,sid,KSMLRCOM,KSMLRSIZ,KSMLRNUM, KSMLRHON, KSMLROHV, KSMLRSES from x$ksmlru , v$session where KSMLRSES=SADDR and KSMLRNUM >2 ;
    f.How much are waiting for Library Cache Latch
    select count(*),event from v$session_wait where event not like '%SQL%' and event not like '%ipc%' and event not like '%timer%' GROUP BY EVENT;
    select count(*),wait_time from v$session_wait where event='latch free' and p2=106 group by wait_time;
    select sid,wait_time,seconds_in_wait from v$session_wait where event='latch free' and p2=106 and WAIT_TIME>1;
    g.Queries identical but aren’t shared.
    SELECT address, hash_value, version_count , users_opening , users_executing,
    substr(sql_text,1,240) "SQL" FROM v$sqlarea WHERE version_count > 10;
    h.Get Biggest chunk of free memory.
    select sysdate, decode( sign(ksmchsiz - 812), -1, (ksmchsiz - 16) / 4,
    decode(sign(ksmchsiz - 4012),-1, trunc((ksmchsiz + 11924) / 64),
    decode(sign(ksmchsiz - 65548), -1, trunc(1/log(ksmchsiz - 11, 2)) + 238,254))) bucket,
    sum(ksmchsiz) free_space, count(*) free_chunks, trunc(avg(ksmchsiz)) average_size,
    max(ksmchsiz) biggest from x$ksmsp
    where inst_id = userenv('Instance') and ksmchcls = 'free' group by
    decode(sign(ksmchsiz - 812),-1, (ksmchsiz - 16) / 4,
    decode(sign(ksmchsiz - 4012),-1, trunc((ksmchsiz + 11924) / 64),
    decode(sign(ksmchsiz - 65548),-1, trunc(1/log(ksmchsiz - 11, 2)) + 238,254 ))) ;
    SELECT KSMCHCLS CLASS, COUNT(KSMCHCLS) NUM, SUM(KSMCHSIZ) SIZ,
    To_char( ((SUM(KSMCHSIZ)/COUNT(KSMCHCLS)/1024)),’999,999.00′)||’k’ “AVG SIZE”
    FROM X$KSMSP GROUP BY KSMCHCLS;
    CLASS     NUM     SIZ     AVG SIZE
    freeabl     19010     34519404     1.77k
    recr     23581     24967956     1.03k
    R-freea     68     1632     .02k
    perm     22     39801268     1,766.75k
    R-free     34     7238192     207.90k
    free     2389     36075980     14.75k
    Watch for trends using these guidelines:
    a) if ‘free’ memory is low (less than 5mb or so) you may need to increase the shared_pool_size and shared_pool_reserved_size. You should expect ‘free’ memory to increase and decrease over time. Seeing trends where ‘free’ memory decreases consistently is not necessarily a problem, but seeing consistent spikes up and down could be a problem.
    b) if ‘freeable’ or ‘perm’ memory continually grows then it is possible you are seeing a memory bug.
    c) if ‘freeabl’ and ‘recr’ memory classes are always huge, this indicates that you have a lot of cursor info stored that is not releasing.
    d) if ‘free’ memory is huge but you are still getting 4031 errors, the problem is likely reloads and invalids in the library cache causing fragmentation.
    -Note says that this query can hang database on HP platforms
    See the shared pool parameters
    column name format a30
    select name,value from v$parameter where name like '%shared_pool%' ;
    select x.ksppinm, y.ksppstvl from x$ksppi x , x$ksppcv y where x.indx = y.indx and lower(x.ksppinm) like '%spin%';
    SELECT count(*) FROM v$latch_children WHERE NAME = 'library cache';
    Shrinking and growing operations from V$SGA_RESIZE_OPS dynamic view:
    select to_char(end_time, ‘dd-Mon-yyyy hh24:mi’) end, oper_type, initial_size, target_size, final_size from V$SGA_RESIZE_OPS where component=’shared pool’ order by end;
    #shared_pool_summary.sql -get an overview of chunks in the shared pool
    select
    ksmchcom contents,
    count(*) chunks,
    sum(decode(ksmchcls, 'recr', ksmchsiz)) recreatable,
    sum(decode(ksmchcls, 'freeabl', ksmchsiz)) freeable,
    sum(ksmchsiz) total
    from
    sys.x_$ksmsp
    where
    inst_id = userenv('Instance') and
    ksmchcls not like 'R%'
    group by
    ksmchcom
    #reserved_pool_summary.sql - get an overview of chunks in the reserved pool
    select
    ksmchcom contents,
    count(*) chunks,
    sum(decode(ksmchcls, 'R-recr', ksmchsiz)) recreatable,
    sum(decode(ksmchcls, 'R-freea', ksmchsiz)) freeable,
    sum(ksmchsiz) total
    from
    sys.x_$ksmspr
    where
    inst_id = userenv('Instance')
    group by
    ksmchcom
    #save_sqlplus_settings.sql -reset sqlplus settings
    set termout off
    store set sqlplus_settings replace
    clear breaks
    clear columns
    clear computes
    set feedback off
    set verify off
    set termout on
    set define "&"
    #restore_sqlplus_settings.sql -reset sqlplus settings
    set termout off
    @sqlplus_settings
    clear breaks
    clear columns
    clear computes
    set termout on
    i.Check the shared pool reserved size status
    SELECT free_space, avg_free_size, used_space, avg_used_size, REQUEST_MISSES, request_failures, last_miss_size FROM v$shared_pool_reserved;
    An ORA-04031 error referencing large failed requests, indicates the Reserved Area is too fragmented. The reserved pool is small when: REQUEST_FAILURES > 0 (and increasing), The DBA should Increase shared_pool_reserved_size and shared_pool_size together. It is possible that too much memory has been allocated to the reserved list. The DBA should Decrease shared_pool_reserved_size, If: REQUEST_MISS = 0 or not increasing
    FREE_MEMORY = > 50% of shared_pool_reserved_size minimum
    col free_space for 999,999,999,999 head “TOTAL FREE”
    col avg_free_size for 999,999,999,999 head “AVERAGE|CHUNK SIZE
    col free_count for 999,999,999,999 head “COUNT”
    col request_misses for 999,999,999,999 head “REQUEST|MISSES
    col request_failures for 999,999,999,999 head “REQUEST|FAILURES”
    col max_free_size for 999,999,999,999 head “LARGEST CHUNK”
    select free_space, avg_free_size, free_count, max_free_size, request_misses, request_failures from v$shared_pool_reserved;
    TOTAL FREE     AVERAGE
    CHUNK SIZE     COUNT     LARGEST CHUNK     REQUEST
    MISSES     REQUEST
    FAILURES
    7,238,192     212,888     34     212,888     0     0
    You should also use hidden and unsupported parameter “_shared_pool_reserved_pct” to control reserved pool. This parameter controls the allocated percentage of shared pool for reserved pool. By default it is %5 of the shared pool and if you use ASMM for memory management you can set this value higher like 10 to allocate reserved pool dynamically. When you set the parameter you will see the shared_pool_reserved_size parameter will be adjusted to the new setting. The parameter can not be modified when instance is started. You can use the query below to see the current value
    select a.ksppinm “Parameter”, b.ksppstvl “Session Value”, c.ksppstvl “Instance Value” from sys.x$ksppi a, sys.x$ksppcv b, sys.x$ksppsv c where a.indx = b.indx and a.indx = c.indx and a.ksppinm = ‘_shared_pool_reserved_pct’;
    Parameter     Session Value     Instance Value
    sharedpool_reserved_pct     10     10
    j.When having multiple subheaps:
    select KSMCHIDX, ksmchcom ChunkComment,
    decode(round(ksmchsiz/1000),0,'0-1K', 1,'1-2K', 2,'2-3K', 3,'3-4K',4,'4-5K',5,'5-6k',6,'6-7k',7,'7-8k',8,'8-9k', 9,'9-10k', '> 10K'), count(*), ksmchcls Status, sum(ksmchsiz) Bytes
    from x$ksmsp where KSMCHCOM = 'free memory' group by KSMCHIDX,ksmchcom, ksmchcls, decode(round(ksmchsiz/1000),0,'0-1K', 1,'1-2K', 2,'2-3K', 3,'3-4K',4,'4-5K',5,'5-6k',6,'6-7k',7,'7-8k',8,'8-9k', 9,'9-10k','> 10K');
    SubPool     SGA_HEAP     CHUNKCOMMENT     size     COUNT(*)     STATUS     BYTES
    1     sga heap(1,0)     free memory     > 10K     34     R-free     7238192
    1     sga heap(1,0)     free memory     3-4K     2     free     6284
    1     sga heap(1,0)     free memory     > 10K     241     free     35707400
    1     sga heap(1,0)     free memory     8-9k     1     free     7712
    1     sga heap(1,0)     free memory     2-3K     4     free     6752
    1     sga heap(1,0)     free memory     0-1K     2090     free     133288
    1     sga heap(1,0)     free memory     9-10k     21     free     188676
    1     sga heap(1,0)     free memory     1-2K     30     free     25868
    If you see lack of large chunks it is possible that you can face with ORA-04031 in near future.
    k.Check shared pool at first glance quick diagnostics
    select 'You may need to increase the SHARED_POOL_RESERVED_SIZE' Description, 'Request Failures = '||REQUEST_FAILURES Logic
    from      v$shared_pool_reserved where      REQUEST_FAILURES > 0
    and      0 != (select      to_number(VALUE) from      v$parameter
    where      NAME = 'shared_pool_reserved_size')
    union
    select 'You may be able to decrease the SHARED_POOL_RESERVED_SIZE' Description,'Request Failures = '||REQUEST_FAILURES Logic
    from      v$shared_pool_reserved where      REQUEST_FAILURES < 5
    and      0 != (select      to_number(VALUE) from      v$parameter
         where      NAME = 'shared_pool_reserved_size')
    l.Memory Usage - object list level view
    •     Owner - Owner of the object
    •     Object - Name/namespace of the object
    •     Sharable Memory - Amount of sharable memory in the shared pool consumed by the object
    select OWNER, NAME||' - '||TYPE object,SHARABLE_MEM
    from      v$db_object_cache where SHARABLE_MEM > 10000
    and     type in ('PACKAGE','PACKAGE BODY','FUNCTION','PROCEDURE')
    order by owner asc ,SHARABLE_MEM desc
    SELECT * FROM (SELECT ROW_NUMBER () over (PARTITION BY NAMESPACE ORDER BY SHARABLE_MEM DESC) ROW_within , NAMESPACE, SHARABLE_MEM, SUBSTR(NAME,1,40) NAME FROM V$DB_OBJECT_CACHE ORDER BY SHARABLE_MEM DESC) WHERE ROW_WITHIN <= 2 ORDER BY NAMESPACE, ROW_WITHIN;
    ROW_WITHIN NAMESPACE SHARABLE_MEM NAME
    1 CLUSTER 2794 C_OBJ#_INTCOL#
    2 CLUSTER 1684 SMON_SCN_TO_TIME
    1 RSRCPLAN 5117 SYS_GROUP

  • Parse CPU to Parse Elapsd

    HI,
    I have a question our DB is showing Parse CPU to Parse Elapsd %:  is very less 8.37. .
    What should be done to overcome this problem....
    actually we are facing a latch free wait event.....iand i have also identofy hot blocks....but i donlt know waht should be the next step...
    can anybody suggest Pase CPU to Parse elapsed

    When i execute the V$latch_children
    I found that today is also greates no. of sleeps is CACHE BUFFE LRY CHAINS
    LATCH# NAME                                                                
          GETS     MISSES     SLEEPS                                               
            50 ges resource hash list                                              
        601847      24245      22350                                               
            50 ges resource hash list                                              
        617442      24184      22367                                               
            50 ges resource hash list                                              
        749689      23959      22403                                               
    LATCH# NAME                                                                
          GETS     MISSES     SLEEPS                                               
            50 ges resource hash list                                              
        612959      24281      22460                                               
            50 ges resource hash list                                              
        753679      24146      22491                                               
            50 ges resource hash list                                              
        610225      24510      22550                                               
        LATCH# NAME                                                                
          GETS     MISSES     SLEEPS                                               
            50 ges resource hash list                                              
        605734      24468      22570                                               
            50 ges resource hash list                                              
        751314      24771      23073                                               
           157 library cache                                                       
    342286141     281771      25970                                               
        LATCH# NAME                                                                
          GETS     MISSES     SLEEPS                                               
           157 library cache                                                       
    280560658     329228      31768                                               
           156 shared pool                                                         
    463957862     289795      49417                                               
           118 KCL gc element parent latch                                         
    328364965     438291      51954                                               
       LATCH# NAME                                                                
          GETS     MISSES     SLEEPS                                               
           118 KCL gc element parent latch                                         
    443999194     772076      91141                                               
           120 KCL freelist parent latch                                           
    909808383    2092535     128985                                               
           120 KCL freelist parent latch                                           
    903524925    2097603     136115                                               
       LATCH# NAME                                                                
          GETS     MISSES     SLEEPS                                               
            93 cache buffers lru chain                                             
    617430181    2728584     382138                                             
    9568 rows selected.SQL> spool off
    I am really finding difficult to post my query here.....

  • Correct SGA size in hpux 24gb?

    Hi guys...
    We have a problemen with performance and a lot of type of latches latch: cache buffers chains.
    We have an hpux server with 24gb and 8 procesors.
    this is the parameters on DB.
    Total System Global Area 4798283776 bytes
    Fixed Size 2075600 bytes
    Variable Size 2583692336 bytes
    Database Buffers 2164260864 bytes
    Redo Buffers 48254976 bytes
    log_buffer integer 47511552
    shared_pool_reserved_size big integer 200M
    shared_pool_size big integer 2064M
    But the problem of latches persist in hard hour of work, I hope someone have some tips to resizing memory.
    best regards.

    "We have a problemen with performance and a lot of type of latches latch: cache buffers chains."
    check for hot blocks through v$latch, v$latch_children and v$bh (high TCH).
    hot blocks are typically index root blocks or small tables.
    strategies can be to increase pct_free to a very large value, forcing the introduction of more blocks so that latching is not located on a single buffer cache chain latch.
    or
    move the hot block to a separate buffer pool.
    or
    have the application code rewritten (cache locally).

  • SGA_TARGET and LOG_BUFFER

    Hello guys,
    i am a little bit confused about setting sga_target and sizing log_buffer manually.
    At first the documentation:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams192.htm#sthref792
    The following pools are manually sized components and are not affected by Automatic Shared Memory Management:
    * Log buffer
    * Other buffer caches, such as KEEP, RECYCLE, and other block sizes
    * Fixed SGA and other internal allocations
    Ok.. now my Oracle 10gR2 database:
    - spfile:
    *.log_buffer=1048576
    *.sga_target=3154116608
    Ok now in my opinion, the log_buffer should not be changed by oracle AMM.
    So lets have a look:
    SQL> show parameter log_buffer
    NAME TYPE VALUE
    log_buffer integer 14254080
    SQL> show sga
    Total System Global Area 3154116608 bytes
    Fixed Size 2074600 bytes
    Variable Size 603981848 bytes
    Database Buffers 2533359616 bytes
    Redo Buffers 14700544 bytes
    Oh ok.... why does oracle change my manually sized value log_buffer from 1MB up to 14MB!!! (have a look at the output of show sga!)
    Hmm and now?
    What is right and what is wrong?
    Maybe someone can clear the confusion...
    Thanks and Regards
    Stefan

    Hi Satheesh,
    this forum is amazing :-)
    But... i try to calculate like your information:
    So have a look at my test database:
    SQL> show sga
    Total System Global Area 2097152000 bytes
    Fixed Size 2072576 bytes
    Variable Size 520093696 bytes
    Database Buffers 1560281088 bytes
    Redo Buffers 14704640 bytes
    SQL> show parameter log_buffer
    NAME TYPE VALUE
    log_buffer integer 14258176
    The lgwr.trc shows:
    Maximum redo generation record size = 132096 bytes
    Maximum redo generation change vector size = 124412 bytes
    And the table entry:
    SQL> select name, count(*) from v$latch_children where name='redo allocation' group by name;
    NAME COUNT(*)
    redo allocation 2
    Ok and now 132096 bytes * 2 = 264192 bytes... and not 14704640 bytes like in show sga or parameter log_buffer.
    Regards
    Stefan

  • Db_writer_processes data sets

    Hi All,
    Can you please educate me on below things. Also, please correct me if i am wrong
    1.
    db_writer_processes controls number of db writers that are been started when instance is initialized. So, once DB is up lets say we have 6 dbwriter process then your buffer cache is splitted in 6 working data sets. Can you please explain what is this datasets are ? or may be if i am wrong .
    2.
    If so this is true how can we find that which dataset is used by which dbwrite processes. I mean how to find one to one mapping for say 0x address- to 0y address is been worked by dbwr1 process and so on. how to find this
    3.
    If we have multiple buffer cache like db_16k and db_32k then how do we map this.
    Reason behind this we are using 12 dbwriter process for we have 12gb of sga and 10gb of pga. Some time we are getting buffer busy waits. So, need to find that we are using multiple buffer pools. So, if it is from there then i can suggest management to use only default block size and not multiple. I already know that multiple buffer pool have overhead of managing one more memory structure so need to investigate and learn from you.
    My idea is to reduce this and then start adding processes if necessary

    Hi Jonathan,
    Thank you very much so here are the things which we can conclude from this. Please correct me if i am wrong as i am new to this whole thing.
    1.
    Excessive db writer processes can be overhead due to each working set requires it's own db lru latches.
    2.
    Excessive db writer processes can slow down I/O due to they need to acquire CPU and then run. But one question here is does all db writer process simultinouses compete for cpu or it waits for one to complete and then go to other cpu. As, i can understand cpu uses serialize mechanism but lets say we have 12 dbwriter among one is writing using one cpu and other cpu is free. So, other process can move to that or db writer process is also serial ?
    3.
    Also, this can lead to wrong buffer waits situation as we can have free buffer in other sets and in one set it won't and process acquire that dbwriter so that it will post this wait event but actually we have other free buffers available. How to find this as how many buffers are available, dirty or in other state for each working set ?
    4.
    NAME TYPE VALUE
    db_32k_cache_size big integer 32M
    So, it means that for 32MB scanning of memory we need 12 data working sets or this 32k block size dbwriter data sets can be used by 16k also ?
    And here is the output from our environment
    SQL> select bfp.bp_blksz,
           bfp.bp_name,
           bfp.bp_size,
           wds.indx wds_index,
           wds.dbwr_num,
           wds.FBWAIT,
           wds.BBWAIT,
           wds.set_latch,
           l.gets,
           l.MISSES,
           l.SLEEPS
        from x$kcbwbpd bfp, x$kcbwds wds, v$latch_children l
    where bfp.bp_size != 0
       and wds.set_id between bfp.bp_lo_sid and bfp.bp_hi_sid
       and l.ADDR = wds.set_latch
    order by bfp.bp_blksz, bfp.bp_name, wds.indx;
      BP_BLKSZ BP_NAME                 BP_SIZE  WDS_INDEX   DBWR_NUM     FBWAIT     BBWAIT SET_LATCH              GETS     MISSES     SLEEPS
         16384 DEFAULT                  370845         24          0       8753       6822 000000053D44E478    2088984        724         39
         16384 DEFAULT                  370845         25          1       8721       7027 000000053D44E9D0    2093594        962         29
         16384 DEFAULT                  370845         26          2       8543       4382 000000053D44EF28    2491595        962         29
         16384 DEFAULT                  370845         27          3       7907       4836 000000053D44F480    2155756       1042         43
         16384 DEFAULT                  370845         28          4       7655       5722 000000053D44F9D8    2131806        978         30
         16384 DEFAULT                  370845         29          5       7270       4440 000000053D44FF30    2117001       1074         34
         16384 DEFAULT                  370845         30          6       8350       2804 000000053D450488    2087645        930         35
         16384 DEFAULT                  370845         31          7       7841       6987 000000053D4509E0    2145802        908         37
         16384 DEFAULT                  370845         32          8       8699       4890 000000053D450F38    2119788        928         35
         16384 DEFAULT                  370845         33          9       8074       4679 000000053D451490    2167632        925         29
         16384 DEFAULT                  370845         34         10       8666       5068 000000053D4519E8    2103990        902         27
         16384 DEFAULT                  370845         35         11      12503       7753 000000053D451F40    2150953        991         38
      BP_BLKSZ BP_NAME                 BP_SIZE  WDS_INDEX   DBWR_NUM     FBWAIT     BBWAIT SET_LATCH              GETS     MISSES     SLEEPS
         32768 DEFAULT                    1012         84          0   11205160   11401610 000000053D462518   37611275     129971       1188
         32768 DEFAULT                    1012         85          1    9643066   11547834 000000053D462A70   36582915     106640       1157
         32768 DEFAULT                    1012         86          2   10446003   11583563 000000053D462FC8   37427372     102028       1088
         32768 DEFAULT                    1012         87          3   10573808   11563144 000000053D463520   37295902     104804       1058
         32768 DEFAULT                    1012         88          4   10408529   11452657 000000053D463A78   37088311     102178       1169
         32768 DEFAULT                    1012         89          5   10339793   11544617 000000053D463FD0   37020968     102712       1097
         32768 DEFAULT                    1012         90          6   10385856   11522059 000000053D464528   37197322     101601       1084
         32768 DEFAULT                    1012         91          7   10379007   11495563 000000053D464A80   37131610      99125        982
         32768 DEFAULT                    1012         92          8   10388032   11491618 000000053D464FD8   37119317     100206       1081
         32768 DEFAULT                    1012         93          9   10437875   11557976 000000053D465530   37188171     100933       1108
         32768 DEFAULT                    1012         94         10   10004858   11523490 000000053D465A88   36865058      89088       1075
         32768 DEFAULT                    1012         95         11   11481299   11509310 000000053D465FE0   38390757     127075       1088
    24 rows selected.Edited by: Taral Desai on Jun 4, 2009 1:25 PM

  • High CPU load with Library Cache Pin wit event.

    Oracle8i Enterprise Edition Release 8.1.6.0.0, 64 bit - Production
    HP-UX B.11.00 U 9000/800 605309363 unlimited-user license
    Currently CPU load is 100% with very less sessions in the database.
    But i am finding Library Cache Pin wait event in top.
    If i query v$latchholder i am not getting any rows..and in v$lacth_children
    SQL> select SID,EVENT,WAIT_TIME,SECONDS_IN_WAIT,STATE from v$session_wait where EVENT='library cache pin';
           SID EVENT                                     WAIT_TIME SECONDS_IN_WAIT STATE
             8 library cache pin                                 0             863 WAITING
            90 library cache pin                                 0            3093 WAITING
            89 library cache pin                                 0            2566 WAITING
            57 library cache pin                                 0           27384 WAITING
            54 library cache pin                                 0           21029 WAITING
            53 library cache pin                                 0            7840 WAITING
            50 library cache pin                                 0            2620 WAITING
            47 library cache pin                                 0            6031 WAITING
            46 library cache pin                                 0            1241 WAITING
            41 library cache pin                                 0           15637 WAITING
           145 library cache pin                                 0             910 WAITING
           133 library cache pin                                 0            5124 WAITING
           111 library cache pin                                 0           15077 WAITING
            98 library cache pin                                 0            6563 WAITING
            94 library cache pin                                 0            2088 WAITING
            93 library cache pin                                 0            4592 WAITING
            92 library cache pin                                 0           14705 WAITING
            91 library cache pin                                 0           14798 WAITING
            36 library cache pin                                 0            1533 WAITING
            33 library cache pin                                 0            1491 WAITING
            28 library cache pin                                 0           13970 WAITING
            25 library cache pin                                 0            7630 WAITING
            11 library cache pin                                 0           12169 WAITING
            12 library cache pin                                 0            2352 WAITING
            14 library cache pin                                 0           19748 WAITING
    SQL> select addr,name from v$latch where name='library cache';
    ADDR             NAME
    C00000006971D460 library cache
    SQL> select latch#,name from v$latch_children where name='library cache';
        LATCH# NAME
           105 library cache
           105 library cache
           105 library cache
           105 library cache
           105 library cachePlease help me out to find actual cause of these latches and fix ?
    -Yasser

    bump
    No-one?
    The problem seems to have 'resolved itself' over the weekend incidentally (although I don't believe anything truly resolves itself in this manner - something must have changed).

  • DB Blocks

    Hi,
    Kindly tell me concepts of hot block in oracle database
    Thanks
    Deepak

    Deepak,
    Usually, when someone talks about "hot blocks" they mean blocks that are very popular and are requested so often that the competition between users that want to access the blocks start to cause performance issues.
    There are two typical symptoms of hot blocks.
    a) buffer busy waits. If there is a lot of competition between many users to modify the same block(s) very frequently, then they have to compete for exclusive access to the block because only one user is alowed to change a block at a time.
    b) increased activity on the 'cache buffers chains' latches. Even if a user is only trying to view the contents of a block, they still have to do some work to find the block and make sure it stays in memory for a while. To do this, the user has to acquire the relevant 'cache buffers chains' latch - so if there are lots of sessions constantly trying to read the same block, then there will be competition for the one relevant latch. (This, particularly, is why Francisco has introduced a script that accesses v$latch_children).
    If you don't see any indications of significant time lost on wait event 'buffer busy waits', or any extreme numbers of get, misses, or sleeps on individual 'cache buffers chains' latches, then you probably have more important things to worry about than hot blocks.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge." (Stephen Hawking)

Maybe you are looking for

  • How to add a new Shared Variable programmatically to an existing and deployed library?

    Hi there! I am trying to accomplish this on both LabVIEW 8.6 and LabVIEW 2010 and seems like it's not any different in this situation. My case: A project has a library with 4 Shared Variables (SVs). The library and the variables are deployed (visible

  • "File Path Control" default Value

    Hi - How do we set or change the default value for "File Path Control" (Control --> String & Path ---> File Path Control)? I typed the default path into the control field on the front pannel and save the VI file.  The value gone when I reopen the fil

  • Trouble sharing photos between devices via iCloud photostream

    I have trouble sharing photos in my iPod 4th generation with an iPad 2 user. I've sent an invitation to an iPad user to share my shared album with him but he didn't receive any email regarding on this invitation. Whereas, when the iPad user invite me

  • Split times in minutes and seconds

    I keep a training log wherein I track my bicycle split times. I need to make entries such as, for example, 5 minutes, 37 seconds(5:37 or 05:37 like a stopwatch). I can't seem to find the proper format for this. It keeps coming up in an am/pm or other

  • Something I noticed after printing out a document

    I was just wondering why you have to save a file again after you print out a document. Does printing change the file or something? I also noticed that this isn't just in Pages. It's in most apps that have to do with printing, like TextEdit and Number