ORA-04031错误分析和解决
查询v$shared_pool_reserved视图可以判断共享池问题的引发原因:
SQL>select FREE_SPACE,AVG_FREE_SIZE,USED_SPACE,AVG_USED_SIZE,REQUEST_FAILURES,LAST_FAILURE_SIZE from v$shared_pool_reserved;
FREE_SPACE AVG_FREE_SIZE USED_SPACE AVG_USED_SIZE REQUEST_FAILURES LAST_FAILURE_SIZE
---------- ------------- ---------- ------------- ---------------- -----------------
2685760 167860 0 0 0 0
如果request_failures>0且LAST_FAILURE_SIZE>shared_pool_reserved_min_alloc,那么4031可能是因为共享池包括空间缺少连续的空间所致;考虑加大shared_pool_reserved_min_alloc,并增大shared_pool_reserved_size和shared_pool_size来加大共享池保留空间的可用内存。
如果request_failures>0且LAST_FAILURE_SIZE<shared_pool_reserved_min_alloc,或者request_failures=0且LAST_FAILURE_SIZE<shared_pool_reserved_min_alloc,那么应考虑降低shared_pool_reserved_min_alloc。
shared_pool_reserved_min_alloc参数值的查询:
SQL>
column name format a35
column value format 9999999
column ISDEFAULT format a5
column ISMOD format a5
column ISADJ format a5
select
x.ksppinm name,
y.ksppstvl value,
y.ksppstdf isdefault,
decode(bitand(y.ksppstvf,7),1,'modified',4,'system_mod','false') ismod,
decode(bitand(y.ksppstvf,2),2,'true','false') isadj
from
sys.x$ksppi x,
sys.x$ksppcv y
where
x.inst_id = userenv('instance') and
y.inst_id = userenv('instance') and
x.indx = y.indx
and x.ksppinm like '_shared_pool%' ---/**_% 查询所有隐含参数’
/
NAME VALUE ISDEF ISMOD ISADJ
----------------------------------- ------- ----- ----- ---------------------------------------------------
_shared_pool_reserved_pct 5 TRUE false false
_shared_pool_reserved_min_alloc 4400 TRUE false false
经验谈:
设置 _shared_pool_reserved_min_alloc=4100 ,不建议设置更低;一般在 4100~4400 之间。