In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to deeply analyze the concept and memory structure of oracle buffer cache. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
The concept of 1.buffer cache
To describe the nature of oracle database in the simplest language is to be able to store data with a pile of files on disk and provide a variety of means to govern the data. The most basic requirement for managing data is to be able to save and read data from files on disk. It is well known that the speed of reading disks is relatively slow, while the relative speed of memory is much faster. Therefore, in order to speed up the processing of data, oracle must cache the read data in memory. Oracle has a name for the data cached in memory: the data cache (db buffer cache), which is usually called buffer cache. According to oracle officials, a buffer cache is an area of memory that contains many blocks of data, which are mainly copies of the contents of blocks in a data file. Specify the size of the buffer cache by initializing the parameter: buffer_cache_size. Once the oracle instance is started, the area size is allocated.
The main functions that buffer cache can provide include:
1) by caching blocks of data, the I _ map O is reduced.
2) by constructing CR blocks, read consistency is provided.
3) by providing various lock and latch mechanisms, multiple processes can access the same data block concurrently.
Memory structure of 2.buffer cache
2.1 Overview of buffer cache
In the process of implementing its governance within oracle, there are two very famous terms: linked list and hash algorithm.
A linked list is a data structure that is formed by concatenating objects together. In this way, if you want to modify, delete, or find an object, you can first look it up in the linked list without actually accessing the physical media. Probably the most famous linked list in oracle is the LRU linked list, which we'll talk about later.
The hash algorithm is a technology used to find and locate quickly. The so-called hash algorithm is according to the value to find, after a certain hash algorithm for the value, get the index number of the value, and then enter into a list of values that should exist (can be understood as a two-dimensional array), through the index number to find which list it should belong to. Then go to the determined list and compare the values contained in it one by one to find the value. This avoids scanning the entire list of values to find the value, which is obviously much less efficient than hash lookups. Where the numeric column corresponding to each index number is called a hash bucket in oracle.
Let's list one of the simplest hash algorithms. Suppose our list of values can have up to 10 elements, that is, 10 hash buckets, and each element can contain up to 20 values. The corresponding two-dimensional array is t [10] [20]. We can define the hash algorithm as n MOD 10. With this algorithm, all incoming data can be evenly placed in 10 hash bucket, with hash bucket numbers from 0 to 9. For example, we put 1 to 100 in these 10 hash bucket evenly through this hash function. When looking for where 32 is, just put 32 MOD 10 equal to 2, so you know that you can find it in hash bucket 2, that is, you can find it in t [2] [20]. There are 10 values in hash bucket 2. Just compare whether 32 exists in hash bucket 2 one by one.
Buffer cache is governed by multiple hash bucket, and its hash algorithm is of course much more complex than what we listed earlier.
It logically explains the structure of the whole buffer cache.
List three nouns: hash bucket, buffer header and hash chain.
The hash bucket here is the first dimension of the two-dimensional array mentioned in the hash algorithm we explained earlier. It is through the buffer header
The block address and block type recorded in the hash algorithm are used to obtain the group number.
The hash chain here is a linked list of all buffer header belonging to the same hash bucket. Actually, hash
Bucket is just a logical concept. Each hash bucket is reflected through a different hash chain. Each hash chain is governed by a cache buffers chains latch that governs its concurrent operations.
For buffer header, when each data block is read into buffer cache, a buffer header,buffer header is constructed in buffer cache to correspond to the data block one to one. The main information contained in buffer header is:
1) the actual memory address of the data block in buffer cache. That's what the dotted arrow in the picture above means.
2) the type of the block, including data, segment header, undo header, undo block, and so on.
3) the hash chain in which the buffer header is located is realized by storing a pointer to the previous buffer header and a pointer to the latter buffer header in the buffer header.
4) LRU, LRUW, CKPTQ and other linked lists where the buffer header is located (we will specify these lists later). It is also realized by recording the buffer header pointer before and after.
5) the status and tag of the data block corresponding to the buffer header.
6) the number of times the buffer header was visited (touch).
7) the list of processes waiting for the buffer header (waiter list) and the list of processes using the buffer header (user list).
In buffer cache, the default number of hash bucket, or the default number of hash chain linked lists, is determined by a hidden parameter:
_ db_block_hash_buckets decided. In my tests, under 8i, the parameter defaults to db_block_buffers × 2, but after 9i, it seems to take a prime number that is less than and closest to db_block_buffers × 2.
On how to in-depth analysis of the concept of oracle buffer cache and memory structure to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.