Increase Shared Pool for erorr # ORA-04031
hi,
what do i need to look at before i increase the shared pool of our database?
there is just the one database instance on the machine.
i am concerned about the repurcussions on the server.
i hope the information below is of help.
db version: 10.2.0.1.0
os: Red Hat Linux 3
SQL> select name, value from v$parameter where name like '%pool%';
name value
shared_pool_size 150994944
large_pool_size 33554432
java_pool_size 50331648
streams_pool_size 0
shared_pool_reserved_size 10066329
buffer_pool_keep
buffer_pool_recycle
global_context_pool_size
olap_page_pool_size 0
thanks,
santosh sewlal
Hi Santosh,
This is what i faced last two days back! Now i am monitoring the Issue! If you got any solutions please let me know how to avoid this!
ORA-04031 error can be due to either an inadequeate sizing of the SHARED POOL size or due to heavy
fragmentation leading the database to not finding large enough chuncks of memory.
You can monitor this with the two events...
alter system set events '4031 trace name errorstack level 3';
alter system set events '4031 trace name heapdump level 3';
Fragmentataion is one of the causes of ora 4031
Please refer these.
1.Article-ID: Note 146599.1
Title: Diagnosing and Resolving Error ORA-04031
2.Article-ID: Note 62143.1
Title: Understanding and Tuning the Shared Pool
3.Article-ID: Note 61623.1
This is paticular for Oracle 9i Rel 2, Hope the same for Oracle 10 G
Regards
Ravi
Similar Messages
-
Increased Shared Pool size longer hot backup time?
Hello,
I have hot backup that usually took 2 hours to complete. Then we had to increase Shared pool size from 280Mb to 380Mb due to some performance issue.
One week after increase of size the hot backup is taking 4 hours to complete. Since there was no other changes to the system I am suspecting size increase
of Shared Pool from 280Mb to 380Mb might be is reason for such drastic increase of backup time.
I would like to get your comments on my suspicion to the problem.
thank youPaul.S wrote:
One week after increase of size the hot backup is taking 4 hours to complete. Since there was no other changes to the system I am suspecting size increase of Shared Pool from 280Mb to 380Mb might be is reason for such drastic increase of backup time.Hmm... at first glance it does not seem that this is the problem.. but perhaps it contributes to it.
When a SQL hits the SQL engine, the 1st thing the SQL engine does is determine if there is an existing parsed and ready-to-use copy of that SQL. If there is, that existing SQL is re-used - thus the name SQL Shared Pool. The resulting soft parse of the SQL is a lot faster (or should be) than a hard parse . A hard parse is where there is no re-usable copy, and the SQL needs to be parsed, validated and execution plan determined, etc.
Kind of like re-using an existing compiled program (with different input data) versus compiling that program before using it. (and that is what source SQL is - a program that needs to be compiled).
Okay, now what happens if there 100's of 1000's of SQLs in your shared pool? The scan that the SQL engine does to determine if there is a re-usable cursor, becomes pretty slow. A soft parse quickly becomes very expensive.
The problem is typically clients that create SQLs that are not sharable (where the input data is hardcoded into the program, instead of input variables to the program). In other words, SQLs that do not use bind variables.
Each and every hardcoded SQL that hits the SQL engine, is now a brand new SQL. And requires storage in the SQL Shared Pool. Shared Pool footprint grows and you start getting errors like insufficient shared pool memory.. and increase the shared pool which means even more space to store even more unique non-sharable SQLs and making soft and hard parses even more expensive.
Like moving the wall a few metres further and then running even faster into it. !http://www.pprune.org/forums/images/smilies2/eusa_wall.gif!
Now if the backup fires off a load of SQLs against the SQL engine, the fast soft/hard parses can now be a lot slower than previously, thanks to a larger shared pool that now caters for more junk than before.
Unsure if this is the problem that you are experiencing.. but assuming that your suspicion is correct, it offers an explanation as to why there can be a degradation in performance. -
Oracle RAC 10.2.0.3 increasing shared pool KQR L PO
Hi,
I've got ORA-04031 on my 4 node 10.2.0.3 Linux RAC.
The top 3 shared pool occupants are:
SQL> r
1 select * from (
2 select * from v$sgastat where pool = 'shared pool' order by 3 desc)
3 where
4* rownum <= 3
POOL NAME BYTES
shared pool KQR L PO 714319616
shared pool sql area 326563888
shared pool free memory 220592728Any idea what is KQR L PO responsible for ?
Regards.
GregHi,
CauseThe shared pool is stressed and memory need to be freed for the new cursors. As a consequence, the dictionary cache is reduced in size by the LCK process causing a temporal hang of the instance since the LCK can't do other activity during that time. Since the dictionary cache is a memory area protected clusterwide in RAC, the LCK is responsible to free it in collaboration with the dictionary cache users (the sessions using cursors referenced in the dictionary cache). This process can be time consuming when the dictionary cache is big.
Solutiona. reduce the stress on the shared pool
=> by increasing it above the automatically reached value with dynamic sga, e.g.
when sga_target is set to 16G and the shared_pool_size was 6G during the hang time, set it to e.g. 8G.
=> by reducing the number of big cursors entering the shared pool, e.g. cursors using more than 1M sharable_mem e.g. via binding
select sql_text from v$sqlarea where sharable_mem > 1M;
b. reduce the dictionary cache usage in order to reduce the size of the dictionary cache, e.g.
=> when dc_histogram_defs is too high, it can point towards histograms calculations on all columns
of the tables. histograms should only be calculated on indexed columns
=> when dc_segments is high compared to dc_object_ids, it can point towards excessive partitioning usage. Reducing the partitions/subpartition usage will help reduce the dictionary cache usage to manage it.
c. set enableshared_pool_durations = false to avoid that one duration (a memory area in the shared pool used for a specific usage) need to give all space required for that usage, i.e. in case the duration containing the dictionary cache need to free memory, then that duration is extra stressed since no other type of memory from other durations can be used. Setting it to false make that any type of memory can be used to free space (i.e. any type of memory in the subpool). As a consequence, the number of subpools will be reduced by the factor of the number of durations (4 in 10gR2). Hence tuning the kghdsidxcount is advisable, e.g. increasing it to have manageable subpool sizes (see note:396940.1).
d. check patch:8666117 has been applied. This patch speedup the processing to free memory
Best regards,
Rafi.
http://rafioracledba.blogspot.com/ -
Keep Sequences in Shared Pool for RAC Environment
Hi,
We have 2 node RAC setup for production environment. I want to pin cached sequences in my database. We are using following command for this purpose.
EXEC DBMS_SHARED_POOL.KEEP('HR.MySeq','Q');
Do I need to execute this command for each single node?Pinning is in the Shared Pool in the SGA. So it is local to an instance.
Therefore, you would need to execute it in each instance (i.e. on each node).
Note : However, with sequences in RAC, you have to be careful with the definition. Have you defined it or do you need to define it as CACHE/NOCACHE ? Have you defined it or do you need to define it as ORDER (to guarantee order generation in RAC) ?
Hemant K Chitale -
How to pin sequences in the shared pool for RAC?
We have a RAC environment with two instances. I want to pin some sequences in the shared pool to boost the performance. Do I need to pin them in both of the instances or just pin them in one instance?
Thanks in advanceIf you cannot tolerate gaps, you must not use sequences. Period. A sequence-generated key will have gaps because transactions roll back, because databases get shut down, etc. If you want to ensure that there are no gaps, you have to write code that serializes access to a resource (i.e. a custom table of sequences) over the full length of a transaction. Of course, this is hugely inefficient and kills the application's scalability, but it does prevent gaps. Sequences are much faster and much more scalable, but they do not and can not guarantee that there are no gaps.
Assuming the intention is to minimize gaps, rather than to eliminate them, NOCACHE & ORDER can help. That means, though, that you may need to communicate with the other nodes in the cluster every time you need a new value from the sequence, which is the slow part. Pinning the sequence is not going to be beneficial.
Justin -
Increase RAM do I need to increase shared pools
If I adjust my RAM by adding 12 GB with gives it 32 GB total, what do my ipc pools have to be set at? especially 10 and 40 on AIX?
What other params do I need? We have a heavy interface with batch jobs from our manafacturing floor systems.
Thanks
MikieHi,
The Virtual memory, it is physical memory ( RAM) and shared memory combined. Which is automatically allocated by the SAP System. So I suspect that we need not tune the shared memory parameters on addition of addtional physical memory.
With regards
Sudha -
Hi All,
DB:oracle9iR2
os:solaris
how to get the shared_pool usage,free total size and hit ratio in oracle 9i R2?,can any one help to me....
POOL BYTES MB
shared pool used :
shared pool free :
shared pool (Total):
=================
Shared_pool hit ratio:
thanks.Hi All,
thank you for all the responses..
Db:oracle 9iR2
os :solaris
Actually i am facing below problem..
prob: ORA-00604: error occurred at recursive SQL level 2
ORA-04031: unable to allocate 4224 bytes of shared memory ("shared pool","select obj#,type#,ctime,mtim...","sga heap(1,0)","library ca
che")
Wed Feb 8 19:33:43 2012
Errors in file /ora/admin/cddp/bdump/cddp_cjq0_2601.trc:
ORA-00604: error occurred at recursive SQL level 2
ORA-04031: unable to allocate 4224 bytes of shared memory ("shared pool","select obj#,type#,ctime,mtim...","sga heap(1,0)","library ca
che")
Wed Feb 8 19:33:43 2012
Errors in file /ora/admin/cddp/bdump/cddp_cjq0_2601.trc:
ORA-00604: error occurred at recursive SQL level 2
ORA-04031: unable to allocate 4224 bytes of shared memory ("shared pool","select obj#,type#,ctime,mtim...","sga heap(1,0)","library ca
che")
Wed Feb 8 19:33:48 2012
Errors in file /ora/admin/cddp/bdump/cddp_cjq0_2601.trc:
ORA-00604: error occurred at recursive SQL level 2
ORA-04031: unable to allocate 4224 bytes of shared memory ("shared pool","select obj#,type#,ctime,mtim...","sga heap(1,0)","library ca
che")
========================================
i was running with 200MB size of share pool....couple of days back un expectdly i got above error....for temparory solution i did shared pool flush...
again nexday same error got repeated....for that i increased shared pool size to 420 MB....
while monitoring db it is using shared pool memory up to 400MB with avg shared pool hit ratio of 94.5 %..(database started recently)...
Earlier shared_pool size:200MB
Now:420 MB
Avg usage:up to 400MB
my question is :
1)if we have many different sql statements in shared pool ..won't
oracle flush share pool (ie aged out based on LRU or some alogorithm) if any program need memory in shared pool?
2) Any data Fragmentation will cause@above error?
3)can any one please explain..... how to check whats going on in Shared_pool(internally)...why it is using 400MB while compare to erlier avg usage 170MB .....any idea...(how to find root cause)..?
4)will plan table cause any issue ?
can any one explain to me...
thanks..
Edited by: kk001 on Feb 11, 2012 4:54 PM
Edited by: kk001 on Feb 11, 2012 4:56 PM -
We got a ORA-04031: unable to allocate 32 bytes of shared memory ("shared pool","select name,online$,contents...","sql area","tmp"). (BTW. What does this "tmp" mean?)
Noone was able to login to server for about 5 minutes and then it came back to life.
I queried system views, and found out that during the time when database was unavalable, our ASMM tried to grow shared pool and shring buffer cache. It returned an error about 300 times, and (around the time when db came to life) suceeded increasing shared pool from 304 MB to 320 MB.
How can i find out what cused the errors during the resize?
Besides that, free memory in shared pool was 164 MB. I did found this document 451960.1, suggesting it could be a bug (not sure if it's fixed in later versions though).
Also, one side question. What exactly is "KGH: NO ACCESS" part of shared pool? As i understand that part is the memory that is in transit during the resizing of buffer cache/shared pool. But why is it so large all the time (400 MB in my case) ? Should it ever shrink? Resize is not happening all the time, and when it is, it's not that large.
Database is 10.2.0.2 on AIX.You need to open TAR in Oracle support.
You can also check streams pool size parameter (it is exists in 9.2.0.6). By default Oracle allocated 10% of shared pool for streams but started from 9.2.0.6 you can change streams pool size. There is some minimum recomendation for streams pool. Looks like your streams pool is very small. -
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,
BalaBhawani 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 -
Hi:
I have been consistently getting this error while executing a scheduled job. "Unable to allocate 4096 bytes of shared memory". A quick search on the problem/solution led me to discussions where bind variables (or lack of them) cause this error to crop up.
My query is:
1. What causes this? Will increasing shared pool size solve this problem permanently? or temporarily?
2. If temporarily, then what options do I have to solve this problem.
The developers seem to be using bind variables already.
Thanks.hi kanwar,
can you please provide more details of where you are scheduling a job in OracleAS Portal ? are you trying to do this from the UI ?
thanks for the clarification.
christian -
Should I use shared pool advisor?
Hi, I am new to the Oracle DB and preparing for the first test of the OCA. If there is a SQL statement that is parsing repeatly, should I use shared pool advisor or SGA advisor?
thanks a lot for helpuser592813 wrote:
Hi, I am new to the Oracle DB and preparing for the first test of the OCA. If there is a SQL statement that is parsing repeatly, should I use shared pool advisor or SGA advisor?
thanks a lot for helpYou need to tell us that what do you mean by "parse" here? Is it a soft parse or hard parse? If its a hard parse, and you have made sure that your application has not used literals , you may look at the shared pool for being undersized by its sizing advisory. If you have a bad code in the application throwing unsharable queries, there is no point of increasing the shared pool as at any one point of time,it would become useless. For this, the fix would be tune the queries and not to resize the shared pool.
If on the other hand, you have soft parsing happening, you can further try to optimize it by making it "no parsing" using the parameter session_cached_cursors . But for this as well, there is no need to increase the size of the shared pool.
HTH
Aman.... -
ORA-04031: unable to allocate 4096 bytes if shared memory
Hello Gurus,
Did anyone got this type of error before:
ERROR:
ORA-20414: Materialized View refresh failed - ORA-12008: error in materialized view refresh path
ORA-04031: unable to allocate 4096 bytes of shared memory ("shared pool","IDX_MIF_SITE","pacdHds_kkpaco","stP_kkpacd: kkpodPacdInit")
Every sunday full refresh of the data warehouse is scheduled. This sunday it didn't complete and gave us the above error. This can be solved by increasing the shared pool memory size. But DBA doesnot want to increase it every sunday(This has been going on for 3 weeks now) and it's not feasible to increase like this everytime.
We want to find the actual cause of it and fix?
Does anyone know the solution or can throw some light on this issue?
Thanks,
SanjayWe want to find the actual cause of it and fix?The cause is simple - you have run out of memory assigned to the Shared Pool in the SGA.
The root cause is more of an issue. The Shared Pool is mostly used for keeping the SQL statements and supporting information (such as cursor support). Each unique SQL statement requires it's own area in the shared pool, however identical statements can used the same (shared) area. Shared Pool is also used to store the 'current' data dictionary (table, view, etc.) information. And in some cases, it's also used for 'large' operations such as direct path insert block builds.
Some of the possible reasons for running out of shared pool might include
- it's simply undersized;
- not enough SQL is actually shareable;
- the large pool has not been allocated.
That second one is frequent when the application builds up SQL statements by concatenating pieces, including literals (user input) and then executing the unique statement. This is a common technique by developers using .Net, Perl or having SQL Server background. (That mode of operation is very susceptible to SQL Injection.)
You can get a lot more info from:
- searching the forum;
- looking in the docco (Concepts manual and Performance Tuning guide);
- books, like Tom Kyte's "Expert One on One Oracle", "Effective Oracle By Design", and newer on apress.com -
ORA-04031 on 10g - should I just adjust my SGA POOL SIZE?
Has anyone gotten this message frequently:
ORA-04031: unable to allocate 37536 bytes of shared memory ("shared pool","unknown object","sga heap(1,0)","session parame")
We are a business intelligence application that issues lots of large queries. We just migrated to 10g and we are seeing this every 2-3 days on our testing machine.
In particular, I am not sure about "sga heap"... I would just set my Shared Pool Size higher - currently 144 MB but will this help here? Thoughts?In Oracle 10g a new feature called "automatic memory management" allows the dba to reserve a pool of shared memory that is used to allocate the shared pool, the buffer cache, the java pool and the large pool.
In general, when the database needs to allocate a large object into the shared pool and cannot find contiguous space available, it will automatically increase the shared pool size using free space from other SGA structure.
Since the space allocation is automatically managed by Oracle, the probability of getting ora-4031 errors may be greatly reduced. Automatic Memory Management is enabled when the parameter SGA_TARGET is greater than zero and the current setting can be obtained quering the v$sga_dynamic_components view.
Please refer to the 10g Administration Manual for further reference
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14231/toc.htm -
ORA-04031: unable to allocate 64 bytes of shared memory
Hi All,
We are performing System copy on a distributed environment with OS Windows 2003 and DB Oracle 10.2.0.4
While importing the Database (ABAP) only ,we are facing error and 5 import steps are failing in Import ABAP phase.
Error is "ORA-00604: error occurred at recursive SQL level 1
ORA-04031: unable to allocate 4120 bytes of shared memory ("shared pool","select user#,type# from user...","Typecheck","kgghteInit")
(DB) INFO: disconnected from DB"
There is already one Oracel Instance OracleXX1 is runing this is the second instance and the server has around 1.75 GB RAM...i
Can you please suggest what could be the error.
Regards
AjayDears,
Please try increase your database parameter shared_pool_size in pfile and then try to resume the activity.
Regards,
Shivam -
ORA-04031: unable to allocate 33568 bytes of shared memory in Oracle 10g
Hi,
I am getting following message frequently while taking export in Oracle 10g database:-
EXP-00008: ORACLE error 4031 encountered
ORA-04031: unable to allocate 33568 bytes of shared memory ("shared pool","DBMS_REPCAT_UTL","PL/SQL MPCODE","BAMIMA: Bam Buffer")
ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_REPCAT_UTL"
ORA-06512: at "SYS.DBMS_REPCAT_EXP", line 87
ORA-06512: at line 1
EXP-00083: The previous problem occurred when calling SYS.DBMS_REPCAT_EXP.schema_info_exp
EXP-00008: ORACLE error 4031 encountered
ORA-04031: unable to allocate 16416 bytes of shared memory ("shared pool","SELECT SYNNAM, SYNNAM, SYNTA...","kgghtInit","kgghtInit")
EXP-00000: Export terminated unsuccessfully
Whats could be the reason?There could be a few reasons causing the problem. From literal message it would look like your shared pool size is small and you need to increase. But the root cause of the problem is a little more complicated than that. I suggest you read metalink doc
Diagnosing and Resolving Error ORA-04031
Doc ID: Note:146599.1
Maybe you are looking for
-
Forum doesn't display correctly at 800x600
I have my browser window at 800x600 because I like to do other stuff while I have it open. However, the Arch forum is too wide for this and doesn't scale down like other phpbb forums. I suspect this is either because of the Google ads or the AUR/Bu
-
Deployable proxy lookup problem
Hello SAP Community, here is my issue: I need to access a web service in my web dynpro application, so I generated a deployable proxy from the wsdl file and deployed it to the server. I added the proxy's ClientAPI.jar to my web dynpro build path and
-
Blackberry 8100 pearl hard boot meltdown!
I have a blackberry pearl 8100, t-mobile version. I have unlocked it and switched to AT&T. I did a hardboot to refresh my memory as it was taking numerous minutes to load my applications, apon re-inserting my battery I get no boot sequence. I get a
-
What can i do if I scratch the itunes card and I can´t see the code?
what can i do if I scratch the itunes card and I can´t see the code?
-
How to download bbm for ipod 5th generation? Help
Please help me