Handling Oracle Database Result Cache Corruption
Result Cache, can be used to cache query and function results in memory. The cached information is stored in a dedicated area inside the shared pool
where it can be shared by other PL/SQL programs that are performing similar calculations.
The Result Cache is set up using the result_cache_mode initialization parameter with one of these three values:
1. auto: The results that need to be stored are settled by the Oracle optimizer
2. manual: Cache the results by hinting the statement using the result_cache|no_result_cache hint
3. force: All results will be cached
At times we come across result cache Contention or Corruption issues which can be easily fixed by disabling and re-enabling result cache . "ORA-600 [qesrcro_dol2ro] / result cache corruption" can be seen in alert log in case of corruption issues .
############## how to check result cache corruption ##############
SQL> SELECT dbms_result_cache.status() FROM dual;
DBMS_RESULT_CACHE.STATUS()
--------------------------------------------------------------------------------
CORRUPT
--> Generate Result Cache Report
SQL> SET SERVEROUTPUT ON
SQL> EXECUTE DBMS_RESULT_CACHE.MEMORY_REPORT
############## Flushing Result Cache ##############
--Flush retaining statistics (default for both are FALSE)
begin
dbms_result_cache.flush (
retainmem => FALSE,
retainsta => TRUE);
end;
/
--Flush Retaining memory (default for both are FALSE)
begin
dbms_result_cache.flush (
retainmem => TRUE,
retainsta => FALSE);
end;
/
--Flush memory and statistics globally
begin
dbms_result_cache.flush(
retainmem => TRUE,
retainsta => FALSE,
global => TRUE);
end;
/
############## Manually Use Result Cache Using Hint ##############
--Use the result_cache hint because manual mode is being used for this instance
select /*+ result_cache */
------------------------------------------
| Id | Operation |
------------------------------------------
| 11 | COUNT STOPKEY |
| 12 | VIEW |
| 13 | RESULT CACHE |
------------------------------------------
############## Disable and re-enable the result cache ##############
alter system set RESULT_CACHE_MAX_SIZE=0;
alter system set RESULT_CACHE_MAX_SIZE=0;
alter system set RESULT_CACHE_MAX_SIZE=125856K
############## other views ##############
select * from GV$RESULT_CACHE_DEPENDENCY;
select * from GV$RESULT_CACHE_MEMORY;
select * from GV$RESULT_CACHE_OBJECTS;
select * from GV$RESULT_CACHE_STATISTICS;
show parameters result
Set line 400
--Check result cache parameters
col name for a30
col value for a30
select
name,
value
from
v$parameter
where
name like '%result%';
--Query the v$result_cache_objects to check if there is any cached object
select
count(*)
from
v$result_cache_objects;
col "Space Over" for a30
col "Space Unused" for a30
col "Obj_Name_Dep" for a30
select
type "Type",
name "Name",
namespace "SQL|PL/SQL",
creation_timestamp "Creation",
space_overhead "Space Over",
space_unused "Space Unused",
cache_id "Obj_Name_Dep",
invalidations "Invds"
from
gv$result_cache_objects;
--Check the Result Cache Setting and Statistics
select
name "Name",
value "Value"
from
v$result_cache_statistics;
--Check objects cached
select
o.owner "Owner",
o.object_id "ID",
o.object_name "Name",
r.object_no "Obj Number"
from
dba_objects o,
gv$result_cache_dependency r
where
o.object_id = r.object_no;
--Checking memory blocks and their status in Result Cache Memory
select * from
gv$result_cache_memory;
Comments
Post a Comment