ResultCache 11g in DNA

Embed Size (px)

Citation preview

  • 8/13/2019 ResultCache 11g in DNA

    1/13

    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

    11g Result Cache in DNA

  • 8/13/2019 ResultCache 11g in DNA

    2/13

    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 loadall nine sections of this page.

    Goal is to deploy a solution/work around such that multiple requestsof 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 aproperty / day

    Solution / Work around : Enable oracle 11g result cache

    http://digitsr.data.yahoo.com:9999/?a=ren&p=lmr-summaryhttp://digitsr.data.yahoo.com:9999/?a=ren&p=lmr-summaryhttp://digitsr.data.yahoo.com:9999/?a=ren&p=lmr-summaryhttp://digitsr.data.yahoo.com:9999/?a=ren&p=lmr-summary
  • 8/13/2019 ResultCache 11g in DNA

    3/13

    Query result set is cachedCached 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 R2Explicity call DBMS_RESULT_CACHE.FLUSH to free memory

    only one latch was controlling result cache. ( problem )

    11g Result Cache - An Introduction

  • 8/13/2019 ResultCache 11g in DNA

    4/13

    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

    11g Result Cache - Queries that Benefit

  • 8/13/2019 ResultCache 11g in DNA

    5/13

    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

    Turn on 11g Result Cache

  • 8/13/2019 ResultCache 11g in DNA

    6/13

    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

    11g Result Cache - Restrictions

  • 8/13/2019 ResultCache 11g in DNA

    7/13

    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)

    DNA Set up - init.ora etc

    http://twiki.corp.yahoo.com/view/OperationsManagement/OracleRacBuildChecklist
  • 8/13/2019 ResultCache 11g in DNA

    8/13

    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.

    11g Result Cache - More Parameters

  • 8/13/2019 ResultCache 11g in DNA

    9/13

    Result Cache Dictionary Views

    V$RESULT_CACHE_STATISTICS :

    V$RESULT_CACHE_MEMORY

    V$RESULT_CACHE_OBJECTS

    V$RESULT_CACHE_DEPENDENCY

  • 8/13/2019 ResultCache 11g in DNA

    10/13

    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 TYPE NAMES CNT_SQL RepeatedScans

    Memory Usage

    (MB) Rows Inval idations

    Repeated Scans

    Over Cnt

    2 DNA_RO Result PLSQL 8 14 0.01 8 0 1.75

    2 MYETL Result PLSQL 158 9287400 0.15 158 0 58781.01

    2 YREPORT Result SQL 5 9 0 5 0 1.8

    3 YREPORT Result PLSQL 226 474 0.22 226 0 2.1

    3 YREPORT Result SQL 656 699 0.94 7176 0 1.074 MYETL Result PLSQL 47 6472 0.05 47 0 137.7

  • 8/13/2019 ResultCache 11g in DNA

    11/13

    Monitoring effectiveness in DNA

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

    Interval Total Sql Scan Hits

    ------------ ------------ ------------

    0 to 5 2734 9525 to 10 46 282

    10 to 15 9 103

    15 to 20 9 149

    20 to 25 2 46

    25 to 30 5 129

    30 to 35 5 16235 to 40 4 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)

  • 8/13/2019 ResultCache 11g in DNA

    12/13

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

    Pointers for further study

    http://www.sfoug.org/Downloads/Oracle11g_Results_Cache_20100304.pdfhttp://www.sfoug.org/Downloads/Oracle11g_Results_Cache_20100304.pdf
  • 8/13/2019 ResultCache 11g in DNA

    13/13

    THANK YOU