NOTE
1.26 MySQL InnoDB Buffer Pool
1. What Is the Buffer Pool - A continuous memory space requested from the operating system when MySQL starts 2. Why the Buffer Pool Is Needed - The speed difference between disk and CPU is too large, so memory is needed as a cache 3. Buffer Pool Workflow - When reading data, read from the Buffer Pool first; if it is present, return it directly, otherwise read it from disk and put it into the Buffer Pool
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is the Buffer Pool
- A continuous memory space requested from the operating system when MySQL starts.
2. Why the Buffer Pool Is Needed
- The speed difference between disk and CPU is too large, so memory is needed as a cache.
3. Buffer Pool Workflow
- When reading data, read from the Buffer Pool first. If it is present, return it directly; otherwise read it from disk and then put it into the Buffer Pool.
- When writing, write to the Buffer Pool and periodically flush it to disk.
4. How the Buffer Pool Is Implemented
4.1. Pages
- Divide the Buffer Pool into cache pages with the same size as a page.
- A control block is allocated at the beginning of each cache page, storing the tablespace number that the page belongs to, page number, address of the cache page in the Buffer Pool, linked-list node information, etc.
4.2. free List
- Used to distinguish which cache pages in the Buffer Pool are free and which have already been used.
- Put the control block corresponding to every free cache page into a linked list as a node.

4.3. Hash Table
- Used to check whether a page is in the cache.
- Create a hash table using
tablespace number + page numberas the key and the cache page as the value.
4.4. LRU List
- When there is no free space in the free list, cold pages in the Buffer Pool can be evicted to load new data.
- The eviction algorithm uses LRU: linked list + Hash.
4.5. flush List
- Used to store modified dirty pages in the Buffer Pool.

5. Using the Buffer Pool
5.1. Configure the Size
[server]
# unit: Byte
innodb_buffer_pool_size = 268435456
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub