Вы находитесь на странице: 1из 13

11g Result Cache in DNA

Why at all did we try Result Cache in DNA ? 11g Result Cache - An Introduction DNA Set up - init.ora etc Monitoring effectiveness in DNA Pointers for further study Q&A

Need for Result Cache in DNA


http://digitsr.data.yahoo.com:9999/?a=ren&p=lmr-summary For a given property and date, it takes more than 90 seconds to load all nine sections of this page. Goal is to deploy a solution/work around such that multiple requests of same property and date can be served with 10 seconds. Bulk of the 90 seconds was spent on querying , disk I/O.. Typical Usage : Different analysts visit the page multiple times for a property / day Solution / Work around : Enable oracle 11g result cache

11g Result Cache - An Introduction


Query result set is cached Cached Data is shared across executions and instances Automatically marked stale if underlying data is changed Uses a Slice of the Shared Pool Flushing Shared Pool doesnot flush result cache. Should test it thoroughly before using it in production. MySQL has this feauture since a long time. 11gR1 issues no longer an issue in R2 Explicity call DBMS_RESULT_CACHE.FLUSH to free memory only one latch was controlling result cache. ( problem )

11g Result Cache - Queries that Benefit


Access Large Amount of Data & Return Few Rows Execute Somewhat Frequently Product Lookups / Customer Info Based on Slowly Changing Data Country / State / County / Zip Code

Remote Database DML does not Invalidate the local results cache Be extra careful on stale results if remote dml. Init.ora : Result_cache_remote_expiration

DNA doesnot remote dmls in DNA

Turn on 11g Result Cache


Choices to enable/use result cache feature :

init.ora : result_cache_mode= FORCE Query Hint : select /*+ result_cache*/ Deptno, sum(sal) from emp group by deptno Table Annotation : alter table emp(mode force) ; Session Mode : alter session set result_cache_mode= force ;

DNA ETL : uses query hint DNA YREPORT uses Session Mode using a logon trigger

11g Result Cache - Restrictions


Wont Work with : Temporary tables SYS or SYSTEM tables Sequences (NEXTVAL or CURRVAL) Date/Time Functions SYSDATE, CURRENT_DATE, SYS_TIMESTAMP, CURRENT_TIMESTAMP, etc USERENV / SYS_CONTEXT (with non-constant variables) SYS_GUID YREPORT DNA : Date is passed as a string

DNA Set up - init.ora etc


Init.ora parameter changes in each reporting instance :

For Reporting Nodes :


Bumped Shared_pool from 4G to 6G result_cache_max_size=512M result_cache_max_result=1 For ETL Nodes : result_cache_max_result= 5 (default)

11g Result Cache - More Parameters


Client_result_cache_size Client_result_cache_lag Sqlnet.ora has few %_RESULT_CACHE_% parameters as well Disabled in DNA. Did not do extensive tests on these. Wip on figuring out which other application can potentially use this.

Result Cache Dictionary Views


V$RESULT_CACHE_STATISTICS : V$RESULT_CACHE_MEMORY V$RESULT_CACHE_OBJECTS V$RESULT_CACHE_DEPENDENCY

Monitoring effectiveness in DNA


Cron @ sp1-portaldb-001:/net/dba/scripts/automation/ResultCacheStickinessRpt.pl
Select Inst_id, UserName, Type, Namespace, Count(*) Cnt_SQL, SUM(Scan_Count) "Repeated Scans", Round(SUM(block_count) * 1024/1024/1024,2) "Memory Usage (MB)" , SUM(ROW_COUNT) "Rows" , SUM(Invalidations) "Invalidations", Round(SUM(Scan_count)/Count(*),2) "Repeated Scans Over Cnt" FROM gv$result_cache_objects a INNER JOIN dba_users b ON (a.creator_uid=b.user_id) WHERE Status = 'Published' AND type = 'Result' Group by Inst_id , UserName , type , Namespace Order by Inst_id;

InstID

USERNAME 2 DNA_RO 2 MYETL 2 YREPORT 3 YREPORT 3 YREPORT 4 MYETL

TYPE Result Result Result Result Result Result

NAMES PLSQL PLSQL SQL PLSQL SQL PLSQL

Memory Usage CNT_SQL RepeatedScans (MB) Rows Invalidations 8 14 0.01 8 158 9287400 0.15 158 5 9 0 5 226 474 0.22 226 656 699 0.94 7176 47 6472 0.05 47

Repeated Scans Over Cnt 0 1.75 0 58781.01 0 1.8 0 2.1 0 1.07 0 137.7

Monitoring effectiveness in DNA

Cron @ sp1-portaldb-001:/net/dba/scripts/automation/ResultCacheStickinessRpt.pl

Interval -----------0 to 5 5 to 10 10 to 15 15 to 20 20 to 25 25 to 30 30 to 35 35 to 40

Total Sql -----------2734 46 9 9 2 5 5 4

Scan Hits -----------952 282 103 149 46 129 162 149

SELECT 5 * TRUNC (scan_count / 5) || ' to ' || 5 * (TRUNC (scan_count/ 5) + 1) "Interval", COUNT(1) "Total Sql", SUM(scan_count) "Scan Hits" FROM gv$result_cache_objects Where Status = 'Published' AND type = 'Result' AND Namespace = 'SQL' GROUP BY TRUNC (scan_count / 5) ORDER BY 5 * TRUNC (scan_count / 5)

Pointers for further study


1) http://www.sfoug.org/Downloads/Oracle11g_Results_Cache_20100304.pdf

THANK YOU

Вам также может понравиться