Memory architecture-sga-database Buffer Cache

Source: Internet
Author: User

Start instance:1, allocate memory space SGA

2. Start the background process

Memory structure: 1, SGA

2. PGA

3, UGA

4. Software code Areas

SGA components:1, Database Buffer Cache

2. Redo Log Buffer

3. Shared Pool

4. Large Pool

5. Java Pool

6. Streams Pool

7. Fixed SGA

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----

Database buffer cache (DB fast caching):

Database Buffer Cache Stores the copies of data blocks in data files. Users who are all in parallel to the same database instance can share access to the Buffer cache.

1, the Database Buffer cache advantages:

A, Optimize physical I/O (optimizes physical I/O)

The database writes the data update to buffer cache, writes the updated SQL statement to redo log buffer, and, after running commit, does not immediately write the data in the buffer cache to disk, but instead writes the redo log Data in buffer is written to disk. Database writer (DBW) performsLazy writes in the background.

b, Keep frequently accessed blocks in the buffer cache and write infrequently accessed blocks to disk (keep frequent use of blocks in buffer Cache, infrequently used write-in disk)

when Database Smart Flash cache (Flash cache) is enabled, part of the buffer caches can reside in the flash cache. This buffer cache extension was stored on a flash disk device, which was a solid state storage device that Uses flash memory. The database can improve performance by caching buffers in flash memory instead of reading from magnetic disk.

2. Buffer States (buffers State):

A, Unused

Buffer not currently in use, can be used by database.

B, clean

Buffer is used before, there is now a consistent read version number at a point in time, database can pin The block in the cache and reuse it.

C, Dirty

The buffer contain modified data, the have not yet been written to disk. The database must checkpoint the block before reusing it.

----------------

Each buffer has access mode:pined or free (that is, unpined), and multiple sessions cannot change the same pined buffer at the same time.

The database uses a sophisticated algorithm to make buffer access efficient. Pointers to dirty and nondirty buffers exist on the sameleast recently used (LRU) List, which have a hot End and cold end. ACold buffer is one of the have not been recently used. A HotBuffer was frequently accessed and has been recently used.

3. Buffer Modes:

A, current Mode

A current mode get, also called a db block get, was a retrieval of a block as it currently appears in T He buffer cache.

B, Consistent Mode

A consistent read get is a retrieval of a read-consistent version of a block. This retrieval could use undo data.
4. Buffer I/O (logical i/o&physical I/O):

logical I/o is buffer I/O, reading or writing to the buffers in buffer cache. Physical i/o,physical I/O occurs when no data is found in the buffer cache to copy the data from the Flash cache or disk to the cache buffer, and then through the logical I/O from the cache The data is read in buffer.

A, Buffer writes

The database writer (DBW) process periodically writes the cold, dirty buffers to disk (that is, the buffers of the LRU queue's Cold end is written to disk).

Dbwn writes buffers to disk under the following conditions:

1: The service process cannot find the clean buffer when the new blocks is read into the database buffer cache.

Assuming that the number of unused buffers falls below the internal threshold, and the clean buffers is requested, Dbwn writes cold, dirty buffers to disk.

The database uses the LRU algorithm to determine which dirty buffer data is written to disk. The database removes the dirty buffer of the LRU queue cold end from the LRU queue and moves to the write queue. Dbwn writes the buffer of the write queue to disk (using Multiblock writes if possible). Such a mechanism makes dirty buffers and clean buffers available.

2:the database must advance the Checkpoint,which is the position of the redo thread from which instance recovery must begi N.

3:tablespace is changed to read-only status or taken offline.

B, Buffer Reads

1:flash Casche Disabled

The database re-uses each of the clean buffer as needed, overwriting it. If the overwritten buffer is needed later and then the database must read it from magnetic disk.

2:flash Cache Enabled

The DBWN can write the body of the clean buffer to the flash cache, which allows space reuse in the cache buffer. The database puts the buffer header into the LRU list. When buffer is requested again, the database can be read from the flash cache, not the disk.

When a client process requests buffer, the search order is as follows:

1:server process Search Entire buffer cache

2:server Process Search Flah buffer header in the cache LRU list

3: Copy disk data to buffer cache (physical read), read data from buffer cache (logical read)

Note: Assuming that buffer is found in step 1 or 2, it is called cache hit and is not found as cache miss

Both the data file and the temp file can occur physical reads. Logical I/O is also performed after the data file is physically read. Temp file bypasses buffer cache and logical I/O does not occur after physical reading. (Database forces data to be written to temporary table when memory is insufficient)

C, Buffer Touch Count

Suppose that a buffer is pinned and the last addition count was at 3 seconds, then Touche Count adds a count. Assuming a buffer is pinned, but the last addition count is no more than 3 seconds, touche count is not counted, keeping the original value (that is, a touch).

Assuming that the touch count value of buffer in the LRU list cold side is larger, the secondary cold buffer is moved to the hot end. Assuming that the touch count value of the LRU list cold side is relatively small, then the buffer is ages out of the cache.

D, buffers and full Table Scans

When the data is written to buffers from disk, the database inserts the buffers into the middle of the LRU list. In such a case, the full table scan may cause a problem: if the total block size in the table is larger than the size of buffer cache, the whole table scan will clean out the buffer cache,preventing the D Atabase from maintaining a cache of frequently accessed blocks. So the full table scan does not work like any other, and when it is full table scan, the blocks in the buffer cache can be reuse immediately.

5. Buffer Pools:

A buffer pool is a collection of buffers. The database buffer cache is divided to one or more buffer pools.

You can manually configure separate buffer pools this either keep data in the buffer cache or make the buffers available F or new data immediately after using the data blocks. You can then assign specific schema objects to the appropriate buffer pool to control how blocks age out of the cache.

The possible buffer pools is as follows:

    • Default Pool

      This pool was the location where blocks is normally cached. Unless manually configure separate pools, the default pool is the only buffer pool.

    • Keep Pool

      This pool was intended for blocks so were accessed frequently, but which aged out of the default pool because of lack of Space. The goal of the keep buffer pool is to retain objects in memory, thus avoiding I/O operations.

    • Recycle Pool

      This pool was intended for blocks that was used infrequently. A Recycle pool prevent objects from consuming unnecessary space in the cache.

The database has a standard block size. When creating tablespace, you can specify a block size that is different from the standard block sizes. Each tablespace that is not the default block size has its own pool. These pool management and default pool management methods are the same.

Memory architecture-sga-database Buffer Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.