Tuesday, November 23, 2010

Oracle - Data Buffer Cache

The Buffer Cache (also called the database buffer cache) is where Oracle stores data blocks.  With a few exceptions, any data coming in or going out of the database will pass through the buffer cache.
The total space in the Database Buffer Cache is sub-divided by Oracle into units of storage called “blocks”. Blocks are the smallest unit of storage in Oracle and you control the data file blocksize when you allocate your database files. 

An Oracle block is different from a disk block.  An Oracle block is a logical construct -- a creation of Oracle, rather than the internal block size of the operating system. In other words, you provide Oracle with a big whiteboard, and Oracle takes pens and draws a bunch of boxes on the board that are all the same size. The whiteboard is the memory, and the boxes that Oracle creates are individual blocks in the memory. 
Each block inside a file is determined by your db_block_size parameter and the size of your “default” blocks are defined when the database is created. You control the default database block size, and you can also define tablespaces with different block sizes.  For example, many Oracle professionals place indexes in a 32k block size and leave the data files in a 16k block size.

When Oracle receives a request to retrieve data, it will first check the internal memory structures to see if the data is already in the buffer. This practice allows to server to avoid unnecessary I/O. In an ideal world, DBAs would be able to create one buffer for each database page, thereby ensuring that Oracle Server would read each block only once. 

The db_cache_size and shared_pool_size parameters define most of the size of the in-memory region that Oracle consumes on startup and determine the amount of storage available to cache data blocks, SQL, and stored procedures. 

The default size for the buffer pool (64k) is too small. It is recommended that you set this to a value of 1m when you configure Oracle.

No comments:

Post a Comment