Oracle
  Home arrow Oracle arrow Page 3 - Generic Architecture for Caching Table...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Generic Architecture for Caching Table Data: Hello Cache, How Are You Doing?
By: Mark Vilrokx
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2005-11-01

    Table of Contents:
  • Generic Architecture for Caching Table Data: Hello Cache, How Are You Doing?
  • The Cache Miss Ratio aka DB Reads
  • The Cache Turnover Ratio
  • Reporting the Ratio

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Generic Architecture for Caching Table Data: Hello Cache, How Are You Doing? - The Cache Turnover Ratio


    (Page 3 of 4 )

    When data is removed from the cache to make room for another record, it is called a turnover.  A cache is most effective if it has a low turnover rate.  The turnover ratio can be calculated by dividing the number of times a record gets removed from the cache, versus the total number of cache hits:

                # Cache Turnovers

    Hit Ratio = ----------------- * 100

                # Cache Hits

    The lower the turnover ratio, the better your cache usage, and the more performance gain you are getting from using the cache.  A high cache turnover can indicate that the cache size is too small, i.e. it can help you pinpoint the issue (cache size too small) when used in conjunction with the Cache Hit and/or Cache Miss ratios.

    In order to be able to calculate the ratio, we just need to keep track of the number of cache turnovers.

       g_total_cache_turnover   PLS_INTEGER    := 0;

    And then we change our existing code to gather the numbers (if requested):

       PROCEDURE write_to_cache (
          p_dept_id     IN   dept.deptno%TYPE,
          p_dept_data   IN   department_tp
       )
       AS
       BEGIN
          IF (g_dept_cache.COUNT >= max_cache_size)
          THEN
             delete_from_cache (random_cached_dept_id);

             IF (gather_stats)
             THEN
                g_total_cache_turnover :=   g_total_cache_turnover
                                          + 1;
             END IF;
          END IF;

          g_dept_cache (p_dept_id).NAME := p_dept_data.NAME;
          g_dept_cache (p_dept_id).LOCATION := p_dept_data.LOCATION;
       END write_to_cache;

    Now we just need to create a procedure to actually perform the calculations of the ratio:

       FUNCTION cache_turnover_ratio
          RETURN NUMBER
       AS
          l_cache_turnover_ratio   NUMBER (10, 5);
       BEGIN
          IF (g_total_reads <> 0)
          THEN
             l_cache_turnover_ratio :=
                                      (g_total_cache_turnover /
    g_total_cache_hits)
                                    * 100;
          END IF;

          RETURN l_cache_turnover_ratio;
       END cache_turnover_ratio;

    Note that your turnover ratio can be 0% and the goal is to get as close to 0% as possible.

    More Oracle Articles
    More By Mark Vilrokx


       · Last in the series, last chance to comment lads.Enjoy,Mark.
     

       

    ORACLE ARTICLES

    - Implementing and Using Oracle`s Restore Poin...
    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT