Database Monitoring   «Prev  Next»
Lesson 11Improving the buffer cache hit ratio
ObjectiveImprove the cache hit ratio.

Improving the buffer cache hit ratio

When using an Oracle RDBMS, if your buffer cache hit ratio[1] is poor, you can usually improve it by "increasing the size of the buffer cache". The size of the buffer cache is controlled by the db_block_buffers initialization parameter. Here is the process for achieving this using the latest version of Oracle 11g.
In Oracle 11g, the method for tuning the buffer cache has evolved. The `db_block_buffers` parameter is deprecated, and the buffer cache size is now managed using the `DB_CACHE_SIZE` initialization parameter. Here's the process to adjust the buffer cache size:
Steps to Increase the Buffer Cache Size in Oracle 11g:
  1. Connect to the Database as SYSDBA:
    • SQL> CONNECT / AS SYSDBA
              
  2. Check the Current DB_CACHE_SIZE:
    • You can query the current buffer cache size with the following command:
      SQL> SHOW PARAMETER db_cache_size;
              
  3. Modify the DB_CACHE_SIZE Parameter:
    • To increase the size of the buffer cache, use the ALTER SYSTEM command. The size can be specified in bytes, kilobytes (K), megabytes (M), or gigabytes (G).
      SQL> ALTER SYSTEM SET db_cache_size = 512M SCOPE=BOTH;
              
    • SCOPE=BOTH: This change will be applied immediately and will also be persistent across database restarts. You can use SCOPE=MEMORY for a temporary change or SCOPE=SPFILE if you want to make the change permanent but not apply it until the next startup.
  4. Verify the Change:
    • Re-run the query to check if the new size has been applied.
      SQL> SHOW PARAMETER db_cache_size;
              

Notes:
  • Automatic Memory Management (AMM): If you are using Automatic Memory Management (AMM) in Oracle 11g, the DB_CACHE_SIZE parameter will be managed dynamically by Oracle. In this case, you may need to adjust the MEMORY_TARGET and MEMORY_MAX_TARGET parameters instead.
  • Avoid Over-Allocating Memory: Ensure you have enough memory on your server to accommodate the increased buffer cache size without causing performance issues.

Oracle 12c DBA
Legacy Tuning for Oracle 8
If your buffer cache hit ratio is poor, you can usually improve it by increasing the size of the buffer cache. The size of the buffer cache is controlled by the db_block_buffers initialization parameter. If you're going to adjust the size, then you should follow this process:
  1. Note the current cache hit ratio.
  2. Increase the db_block_buffers parameter.
  3. Stop and restart the database.
  4. Note the new cache hit ratio.
  5. If a significant increase has occurred, go back to step 2 and increase the buffer cache some more.
  6. If a significant change has not occurred, back out the current change and run with the previous buffer cache size.
At some point, your hit ratio will level out, and increasing the buffer cache further won't affect the hit ratio. The idea is to detect that leveling-out point and size the buffer cache just large enough to achieve it. The following mouseover illustrates this more clearly:
A buffer cache size
First vertical bar
A buffer cache size of 5,000 results in a hit ratio of 0.60.
Second vertical barIncreasing the cache size to 6,000 buffers yields a large increase in the hit ratio, which is now 0.80.
Third vertical barGoing up to 7,000 buffers yields a smaller increase, and the hit ratio is now 0.90.
Fourth vertical barFurther increasing the cache to 8,000 buffers yields an even smaller increase, taking the hit ratio to 0.95.
Fifth vertical barIncreasing the cache from 8,000 to 9,000 buffers results in no increase to the hit ratio. You should undo this change and run with an 8,000 buffer cache.


You may be tempted to increase the buffer cache beyond the point at which the hit ratio levels off. Don't do that--there's absolutely no benefit. you will just be wasting memory that you may be able to use profitably elsewhere.
In the next lesson, you will compute the buffer cache hit ratio for a specific period of time.

[1] buffer cache hit ratio: In Oracle RDBMS, the "buffer cache hit ratio" is a key performance metric that indicates the percentage of data block requests satisfied from the buffer cache in memory, avoiding the need to read from disk. A high buffer cache hit ratio generally means better performance as it reduces expensive disk I/O operations and speeds up data retrieval.

SEMrush Software