Oracle
  Home arrow Oracle arrow Page 4 - 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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

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


    (Page 4 of 4 )

    After all this data gathering you probably would want to report on the data, so let's write a procedure that writes all the ratios to the screen:

       PROCEDURE log_ratios
       AS
       BEGIN
          DBMS_OUTPUT.put_line ('Hit Ratio Miss Ration Turnover Ratio');
          DBMS_OUTPUT.put_line ('--------- ----------- --------------
    ');
          DBMS_OUTPUT.put_line (   LPAD (TO_CHAR
    (cache_hit_ratio,'9990.00'), 7)
                                || ' %'
                                || ' '
                                || LPAD (TO_CHAR
    (db_hit_ratio,'999990.00'), 9)
                                || ' %'
                                || ' '
                                || LPAD (TO_CHAR
    (cache_turnover_ratio,'999990.00'), 12)
                                || ' %'
                               );
       END log_ratios;

    As usual, you can do whatever you want with these ratios, you don’t have to write them to the screen.  You can store them in a table, e.g. to see how your cache’s ratios evolves over time.  That way you can spot trends and act pro-actively, e.g. adjusting the cache size if over time the turnover ratio worsens.

    Notice that these ratios are also session specific. If you lose your connection or reconnect, the ratio components will get reset (to NULL).  If you want to record ratios spanning several sessions you will have to store the values of the ratio components at the end of your code, and restore them at the beginning. 

    On the other hand, if you do not want to record over several sessions and not even over different runs of your code in the same session, you will have to reset the cache manually.  You can add a Cache Reset procedure to your package that you call at the start of your code.  That way the ratio components are always the same (zero) at the start of your program, regardless of whether you just started a session, or have been in that same session for a while.

       PROCEDURE reset_stats
       AS
       BEGIN
          g_total_reads := 0;
          g_total_cache_hits := 0;
          g_total_db_hits := 0;
          g_total_cache_turnover := 0;
       END reset_stats;

    Conclusion

    This concludes the series on my Caching Architecture.  We have seen how to create a cache for our PL/SQL applications and how to make good use of it.  You should now be able find good candidate queries for caching and just follow the architecture to implement good caching logic.  Hopefully you can put this into good practice and your customers or manager will thank you for the fine job you did on improving the performance of the application.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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

       

    ORACLE ARTICLES

    - 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
    - Focusing on Templates in Oracle HTML DB





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway