Packaged procedures in shared pool?

I have a question. Maybe someone can help me.
When I call a standalone stored procedure, this is loaded in the shared pool and it is available for other users too. That's right, I think.
But what about a packaged procedure? When I call one of the elements declared in the package spec the whole package is loaded in memory. It seems to me that is only for my session. Or is a package, including it's subprograms and global declared variables, also loaded in the shared pool and available for other users, after it is called by a user?

> It seems to me that is only for my session.
What test is that based on?
> Or is a package, including its subprograms and global declared variables, also loaded in the shared pool and available for other users, after it is called by a user?
Yes.

Similar Messages

  • What server side objects to pin in shared pool?

    On the first invocation of Java-based image.process(...), processing can take up to 30 seconds. Second run takes less than a second, but a final invocation a few hours later is back to 30 seconds. My DBA suspects that the server side objects are cached in the shared pool by the time of the second invocation, and then flushed out by the time the code is run a few hours later.
    We tried "pinning" ORDSYS.OrdImage pl/sql package in the shared pool using dbsm_shared_pool.keep , but no success. What are the the Java server-side objects referred to the Intermedia Java Client that really does the work when the client-side image.process(..) is executed?
    Thanks,
    Brandon

    hi Mr.kesavan!
    i tried .but i am getting some error.
    when i give lookup (jndi) that time it is giving some error.
    for example :
    ic.lookup("Bean2");exactly this line i am getting some unmarshalling error.
    Can u give me some sample code.?
    thank u...
    Shalinipriya.

  • With create procedure, How to clear Shared pool

    Hi, I have a sql script file it contains
    more than 300,000 line code, I use this file
    to create procedure in the Oracle.
    When I execute this sql script file, I receive a error message " out of cursor". I know when I create procedure, the procedure's code is stores in the shared pool. So when the code is stores out of shared pool's size, I receive that error.
    But how can I clear shared pool? With commit statement, it won't be use.
    Thanks a lot.

    you may try:
    alter system flush shared_pool;
    null

  • Keeps an object in the shared pool

    hello all
    please tell me, when should we keep an object in the shared pool?how can we find out which should be kept in shared pool? please tell me in detail..........
    thank you all in advance

    mohammed_dba wrote:
    hi dear,
    please tell me how can find out which package is frequently pins? please give query for thatI guess you mean which packages are frequently accessed and are candidate for the pinning in the keep pool.
    Use the following query:
    SELECT substr(owner,1,10)||'.'||substr(name,1,35) "Object Name",
    ' Type: '||substr(type,1,12)||
    ' size: '||sharable_mem ||
    ' execs: '||executions||
    ' loads: '||loads||
    ' Kept: '||kept
    FROM v$db_object_cache
    WHERE type in ('TRIGGER','PROCEDURE','PACKAGE BODY','PACKAGE')
    AND executions > 0
    ORDER BY executions desc,
    loads desc,
    sharable_mem desc;Then check which objects have high value for the EXECS column. Also consult with your application developers to identify the frequently used code.
    regards

  • Script to find the " List of objects to be pinned in the shared pool"

    hi all,
    please suggest me any script is there to find the recommended objects to be pinned in to shared pool.
    Regards,
    Vamsi.

    I think the important question here is – do you really need to PIN objects? Are you facing any ORA-4031 errors?
    Oracle would tell you to PIN packages such as STANDARD, DBMS_STANDARD, DBMS_UTILITY, DBMS_OUTPUT. It really depends on your application. So I am afraid there is no exact answer for that, but you can work with your application team to learn if there is some large object that is very frequently used that you might want to PIN.
    I suggest that you check the larger objects from your SGA using the view v$db_object_cache that folks already pointed out checking the column SHARABLE_MEM.
    You can refer to v$sql or v$sqlarea (which is a grouping of v$sql) to find the most executed stored procedures and packages and so on.
    However, most of the problems shared pool problems I have faced were related to bad application coding - such as lack of bind variables - or shared pool undersized. Once those problems were fixed, I hardly had to PIN anything into the SGA.
    Regards

  • 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

  • Shared versus dedicated connections in the fragmentation of shared pool mem

    Hi,
    I have a old Oracle 8.1.7 database server.
    I have a legacy application with no source code. This application don't use memory efficiently (no bind variables, etc.) , ie memory becomes fragmented.
    I know that exists two ways to connect the database (dedicated and shared)
    Based on this, I want to know which of the two options creates more fragmentation. I know that recommendation is to use dedicated connection, but I'm not sure if this is recomendation is applicable in this particular environment.
    Thanks in advance.

    Whether you use shared or dedicated connections makes no difference for fragmentation in the shared pool. Whether your hard parse or do not hard parse does matter.
    Measures you can take
    - make sure often used packages like dbms_standard are pinned in the shared pool using a startup trigger
    - set session_cached_cursors to 50 or 100. This will reduce parsing.
    Sybrand Bakker
    Senior Oracle DBA

  • How can I create packages procedure & function in user-define Library

    hi.
    i am already created packages procedure & function in database and use so on.
    now i would like to create these in library file.
    please anyone give me example of any procedure or function to store in library.
    thanks
    Ali

    <FONT FACE="Arial" size=2 color="2D0000">> please send me one simple example for create library
    then create any function in library.
    2nd is any package can be create in library or not??
    Thanks S.K
    AliHave you checked the link?
    A simple example is provided.
    I think What I understood from your post is that, you want to put function/ Proc and want to call that as Library ..
    Which is not  possible.
    For exampel an external routine is a third-generation language procedure stored in a
    dynamic link library (DLL), registered with PL/SQL, and called by the DBA to perform
    special-purpose processing.
    In Unix a dynamic link library is known as a shared object (so).
    At run time, PL/SQL loads the library dynamically, then calls the routine as if it were a
    PL/SQL subprogram. To safeguard our database, the routine runs in a separate address
    space, but it participates fully in the current transaction. Furthermore, the routine can
    make a call back to the database to perform SQL operations.
    To identify a DLL we have to use CREATE LIBRARY command.
    The CREATE LIBRARY command is used to create a schema object, library, which
    represents an operating-system shared library, from which SQL and PL/SQL can call
    external third-generation-language (3GL) functions and procedures.
    Learn something more on External Procedures
    -SK
    </FONT>

  • Creating a script to purge particular cursor in shared pool

    hi Guys, not good in scripting need help
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    SQL> !uname -a
    SunOS 5.10 Generic_142909-17 sun4u sparc SUNW,SPARC-Enterprise
    SQL>
    we want to purge the cursor for particular sql id if the version_count exceeds more than 100 in shared pool.
    So the action plan is
    create a script and put in cron that will
    select sql_id, version_count from v$sqlarea where sql_id ='32543gwegfdsg';
    1 if version_count >100
    then
    select address, hash_value from v$sqlarea
    where sql_id = '32543gwegfdsg';
    ADDRESS HASH_VALUE
    00000004FBDBE8D8 455331075
    execute the procedure
    exec sys.dbms_shared_pool.purge('&address, &hash_value','c')
    Edited by: ricky on 19-Aug-2011 12:43 PM
    Edited by: ricky on 19-Aug-2011 12:43 PM
    Edited by: ricky on 19-Aug-2011 1:00 PM

    exec sys.dbms_shared_pool.purge('&address, &hash_value','c')is V11.1 that much different from V11.2 for PURGE arguments?
    SQL> desc dbms_shared_pool
    PROCEDURE ABORTED_REQUEST_THRESHOLD
    Argument Name               Type               In/Out Default?
    THRESHOLD_SIZE           NUMBER               IN
    PROCEDURE KEEP
    Argument Name               Type               In/Out Default?
    NAME                    VARCHAR2          IN
    FLAG                    CHAR               IN     DEFAULT
    PROCEDURE PURGE
    Argument Name               Type               In/Out Default?
    NAME                    VARCHAR2          IN
    FLAG                    CHAR               IN     DEFAULT
    HEAPS                    NUMBER               IN     DEFAULT
    PROCEDURE SIZES
    Argument Name               Type               In/Out Default?
    MINSIZE               NUMBER               IN
    PROCEDURE UNKEEP
    Argument Name               Type               In/Out Default?
    NAME                    VARCHAR2          IN
    FLAG                    CHAR               IN     DEFAULT

  • Sql parse and shared pool

    hi friends i have a procedure
    and its have *(AD IS NULL OR NVAD LIKE AD||'%') AND (SOYAD IS NULL OR NVSOYAD LIKE SOYAD||'%')*
    if i use this query and pass different things for AD ; is it become a brand new query for oracle because of ||'%' or its parse and put in shared pool and for a sometime this query don't parse and take from shared pool
       PROCEDURE P_YENI_TALEP_LISTELE(RC_CURSOR OUT SYS_REFCURSOR,TOPLAM_TALEP OUT NUMBER,SAYFA_INDEX IN NUMBER,SAYFA_BUYUKLUK  IN NUMBER,TC_NO IN NVARCHAR2,AD IN NVARCHAR2,SOYAD IN NVARCHAR2,ONAY IN NUMBER,H_TIP_ID IN NUMBER)
        AS 
        BEGIN
          OPEN RC_CURSOR FOR  SELECT TA.NT_ID,TA.NTC_NO,HI.NVHIZMET_TUR AS NVARM_KONU,TA.NVOPRTR_CVP,TA.NVGRSM_SURE,TA.NVGRSM_DRM,
                       TA.NHIZMET,TA.BONAY,TA.DTLP_TRH,TH.NVAD,TH.NVSOYAD,TH.NVILCE ,TA.DALINAN_TRH,
                       TA.DBRKLAN_TRH,TA.NG_ID,GU.NVAD1||' - '||GU.NVAD2 AS GUZERGAH,HI.NH_TIP_ID,HT.NVHIZMET_TIP,
                FROM H_TALEP TA,TNM_HASTA_BILGI TH,TNM_HIZMET HI,SBT_HIZMET_TIP HT,TNM_GUZERGAH GU
          WHERE TA.NTC_NO=TH.NTC_NO AND TA.NH_ID=HI.NH_ID AND HI.NH_TIP_ID=HT.NH_TIP_ID AND(TC_NO IS NULL OR TA.NTC_NO=TO_NUMBER(TC_NO)) AND TA.NG_ID=GU.NG_ID AND
                          *(AD IS NULL OR NVAD LIKE AD||'%') AND (SOYAD IS NULL OR NVSOYAD LIKE SOYAD||'%')*...............

    The code you have posted has no DYNAMIC SQL in it.... Static SQL inside PL/SQL will bind all the variables for you.
    So what you are saying does not compute.
    What is making you think a 'brand new query' is being parsed for each execution?
    Edited by: Tubby on Nov 8, 2008 4:19 PM

  • Extending Shared Pool

    Dear buddies,
    I am receiving this error:
    ORA-04031: unable to allocate 32884 bytes of shared memory ("shared pool","grant select on query....","sql area","qry_text : ....")
    In order to solve this, I need to give more space for the shared pool?
    The total RAM size is 3.82GB(in My Computer's properties)
    The current shared pool size is
    I just performed a full backup and also made a copy of the init file.
    The current value of:
    shared_pool_size = 100M
    sort_area_retained_size = 1048576
    sort_area_size = 1048576
    pga_aggregate_target = 30M
    large_pool_size = 8m
    log_buffer = 163840
    So, in order to extend the space, how can I do it?
    Just change the value to 200M? Is that okay? Some development is going on, and some packages are being compiled. Everything has been stopped after receiving this error. I should shut down, change the value and restart the database?
    Please advice me.
    Thanks in advance.
    Cheers.
    Nith
    Edited by: user645399 on May 25, 2010 1:04 PM

    Hi,There are two matter.
    1.If you use automatic shared memory management(ASMM) then do followings:(To enabling this feature
    you have to set sga_terget != 0 and statistics_level != basic).
    sqlplus "/as sysdba"
    show parameter sga_target; --then will return current value
    alter system set sga_max_size=<newsize> scope=spfile
    alter system set sga_target=<newsize> scope=spfile
    then restart database;
    shutdown immediate;
    startup;
    2.Else you can increase dynamically as:
    sqlplus "/as sysdba"
    show parameter shared_pool_size ; --then will return current value
    alter system set shared_pool_size=<newsize>.
    if you use pfile then you can use above method but also you have to change pfile

  • Flush Shared Pool without Alter System Priv

    I am trying to device a way to flush the shared pool by a user who doesn't have ALTER SYSTEM priv. I tried creating a stored proc in user's schema who has DBA role
    with the following:
    execute immediate 'alter system flush shared_pool';
    and then granted execute on this to a normal user without explicit alter system priv, but the execution fails and seems that I need to grant alter system explicitly to this user. Is there any other workaorund for this?
    Thank You
    Kevin

    it works for me! V10.2.0.4 too.
    SQL> set time on
    12:11:24 SQL> @privs
    12:11:28 SQL> SET TERM ON ECHO ON
    12:11:28 SQL> SET SERVEROUTPUT ON
    12:11:28 SQL> CREATE USER PTST IDENTIFIED BY PTST DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON users TEMPORARY TABLESPACE TEMP;
    User created.
    12:11:28 SQL> grant create session to ptst;
    Grant succeeded.
    12:11:28 SQL> grant alter system to dbadmin;
    Grant succeeded.
    12:11:28 SQL> connect dbadmin/admindb
    Connected.
    12:11:28 SQL> set term on echo on
    12:11:28 SQL> create or replace procedure flush_pool
    12:11:28   2  as
    12:11:28   3  begin
    12:11:28   4  execute immediate 'alter system flush shared_pool';
    12:11:28   5  end flush_pool;
    12:11:28   6  /
    Procedure created.
    12:11:28 SQL> grant execute on flush_pool to ptst;
    Grant succeeded.
    12:11:28 SQL> connect ptst/ptst
    Connected.
    12:11:28 SQL> SET TERM ON ECHO ON
    12:11:28 SQL> execute dbadmin.flush_pool;
    PL/SQL procedure successfully completed.
    12:11:29 SQL> connect / as sysdba
    Connected.
    12:11:29 SQL> drop user ptst;
    User dropped.

  • InterMedia Image Import & Shared Pool Problem

    Hi All
    I have a SYS.ImagePkg.ImportImage stored procedure that its body described below:
    (dest_nid number, filename varchar2, img_date varchar2) is
    img_blob BLOB;
    ctx raw(64) := null;
    file_string varchar2(4) := 'file';
    dir_string varchar2(8) := 'IMAGEDIR';
    begin
    delete from ImageTable where NID = dest_nid;
    insert into ImageTable (NID, Image, ImageDate)
    values (dest_nid, empty_blob(), img_date)
    returning Image into img_blob;
    ORDSYS.ORDImage.importFrom(ctx, img_blob,
    file_string, dir_string, filename);
    update ImageTable set image=img_blob where
    NID=dest_nid;
    commit;
    end;
    this stored procedure inserts an image into database. Also we have a VB
    application that includes this code:
    Set prm1 = cmd.CreateParameter("dest_nid", adNumeric, adParamInput)
    Set prm2 = cmd.CreateParameter("filename", adVarChar, adParamInput, 14)
    Set prm3 = cmd.CreateParameter("img_date", adVarChar, adParamInput, 8)
    '-- Append parameters to command object
    cmd.Parameters.Append prm1
    cmd.Parameters.Append prm2
    cmd.Parameters.Append prm3
    For Each tFil In fld.Files
    temp = Mid(fld.Path + "\", 7)
    temp = RemoveCharacters(temp, "\")
    nid = temp
    crDate = Format(tFil.DateLastModified, "yyyy/MM/DD")
    crDate = RemoveCharacters(crDate, "/")
    cmd.CommandText = " call sys.ImagePkg.ImportImage(?, ?, ?) "
    '-- Assign Parameter Values
    cmd(0).Value = Val(nid)
    cmd(1).Value = nid + ".jpg"
    cmd(2).Value = crDate
    cmd.Execute
    Next
    Automatic Shared Memory Management is Enabled and Shared pool size is 400M at startup. Also library cache size is 4M. But when we start application run, Insertion rate decreses from 45000 records per hour to 14000 records per hour after 44 hours and library cache size increases to 116M.
    If continue running of application, approximatly after 5 days I recieve below error:
    ORA-04031: unable to allocate 4096 bytes of shared memory ("shared pool","select /*+ rule */ bucket, e...","Typecheck heap","kgghteInit")
    and application can not insert any record.
    Please help me to solve this problem.

    Also, I would like to pitch the use of the image type rather than use of a database blob.
    The media types, such as ORDImage, are native server datatypes. These
    datatypes allows the database, and media aware tools and applications to
    understand that a column or table contains media. This is similar to the
    way that the DATE datatype allows the understanding that a column contains
    a date.
    The media types include the most common meta-data, such as mimetype, that is
    needed by media applications. Without this meta-data, an application must
    decide where and how this meta-data is to be stored and retreived. Perhaps extra
    columns or tables in the database, or an application header in the binary data.
    It is possible to store media in simple BLOBs, but by doing this, we take the
    understanding of what is in the database out of the database, and put it into
    the your application realm. Media aware applications and tools, existing
    and future, will not be able to work easily with the media. Only your
    application, or a new application you write specifically without the
    advantage of media aware programming wizards, will be able to work well with
    your media.
    Storing media data into a BLOB is like storing a date in a text column, you
    lose the intrinsic knowlege of what the column represents with the adverse
    effect of media aware applications, tools and wizards not being able to work
    effectively with the column, if at all.

  • 100% CPU, wait event : latch shared pool

    I have a store procedure, run in one of database, it hangs in a "create table ... as select ..." statement.
    the wait event is : latch shared pool, and CPU is up to 100%, it has run over few hours and seems hang.
    Same stored procedure run on others enviroment, never seen such problem, even run on the same data size or even much much bigger data size.
    This procedure has been used more than 2 years, never see such problem in any others enviroment. it only happend in this new setup enviroment.
    however, in this enviroment, if I try to reduce data to be very very small, I was able to see procudure complate in 10 sec.
    I suspect parameter, for example, I changed shared_pool_size from 40MB to 150 MB, re-start database and re-run, still see the same problem here.
    Could anybody suggest any thing I can look into?
    Thanks

    jjzz wrote:
    I have a store procedure, run in one of database, it hangs in a "create table ... as select ..." statement.
    the wait event is : latch shared pool, and CPU is up to 100%, it has run over few hours and seems hang.
    If it's running at 100% CPU, it's not waiting.
    Does v$session_wait (or even v$session since you seem to be running 10g) tell you that the session is *"waiting"*, or is it simply noting that your last wait was on the shared pool latch ?
    If the latter, then you probably have some SQL in the procedure that has changed its execution plan to become much more CPU intensive - perhaps because of a small change in the data volume, data distribution, or statistics.
    First step - find out what SQL statements are executing, and see how much work they are doing. You could query v$session for that session a few times and check what the sql_id and sql_child number are, also prev_sql_id and prev_child_number. If these stay constant, one or other may give you the guilty SQL statement. If not check v$open_cursor for the session.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan

  • Is it recommened to flush shared pool after taking statistics??

    Hi, all.
    The database is 2 node RAC 10.2.0.2.0 on 32-bit windows 2003 EE SP1.
    I stoped the default statistics-gathering-job of GATHER_STATS_JOB
    because it takes statistics of all objects in database and it runs everyday.
    In addition, it seems to cause "library cache related" wait events in a RAC
    environment.
    I have a plan to take statistics of ONLY an application schema, not all objects
    of a database, by using GATHER_SCHEMA_STATS procedure.
    Is it recommended to flush shared pool after taking statistics of an application
    schema??
    Thanks and Regards.

    Is it recommended to flush shared pool after taking
    statistics of an application
    schema??neednt cause whenever you gather stats either its system or not oracle age out the plan and regenerate the new plan on the basis of new gathered stats,see how oracle is smart.
    SQL> create table t as select rownum a,object_name
      2    from all_objects
      3  /
    Table created. 
    SQL> alter system flush shared_pool
      2  /
    System altered.
    SQL> alter session set sql_trace=true
      2  /
    Session altered.
    SQL> declare
      2   va  t.a%type;
      3  begin
      4   for i in 1..100
      5   loop
      6    execute immediate 'analyze table t compute system statistics';
      7    select a into va
      8      from t
      9     where a=i;
    10   end loop;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SELECT a from t
       where a=:b1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.12       0.11          0          0          0           0
    Fetch      100      0.26       0.32          0      11800          0         100
    total      201      0.39       0.44          0      11800          0         100
    Misses in library cache during parse: 1
    Misses in library cache during execute: 99
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
          1  TABLE ACCESS FULL T
    Misses in library cache during execute: 99 shows you aging out the plan after every gathering stats.
    Khurram

Maybe you are looking for