Friday, July 18, 2008

Concept of Cache hit ratio

What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?

A cache is a block of memory for temporary storage of data likely to be used again. The
CPU and hard drive frequently use a cache, as do web browsers and web servers.

A cache is made up of a pool of entries. Each entry has a datum (a nugget of data) which is a copy of the datum in some backing store. Each entry also has a tag, which specifies the identity of the datum in the backing store of which the entry is a copy.

When the cache client (a CPU, web browser, operating system) wishes to access a datum presumably in the backing store, it first checks the cache. If an entry can be found with a tag matching that of the desired datum, the datum in the entry is used instead. This situation is known as a cache hit. So, for example, a web browser program might check its local cache on disk to see if it has a local copy of the contents of a web page at a particular URL. In this example, the URL is the tag, and the contents of the web page is the datum. The percentage of accesses that result in cache hits is known as the hit rate or hit ratio of the cache.

The alternative situation, when the cache is consulted and found not to contain a datum with the desired tag, is known as a cache miss. The previously uncached datum fetched from the backing store during miss handling is usually copied into the cache, ready for the next access.

During a cache miss, the CPU usually ejects some other entry in order to make room for the previously uncached datum. The
heuristic used to select the entry to eject is known as the replacement policy. One popular replacement policy, least recently used (LRU), replaces the least recently used entry.

Oracle DB is based on caching and reusability.


Below mention hit ratio affect oracle database performance

  • Library cache HIT ratio by v$librarycache
  • Dictionary cache HIT ratio by v$rowcache
  • Buffer cache HIT ratio should be more than 90% but at the same time Physical read and write should also be considered. (V$SYSSTAT).

    The cache miss ratio is the number of cache misses compared to the total number of cache read attempts.

This is calculated as follows:

  • Select sum(getmisses) / sum(gets) "Miss ratio" From v$rowcache;


The miss ratio should be less than 15%. If this is not the case, increase the initialization parameter SHARED_POOL_SIZE.