Detailed explanation of MySQL's FreeList mechanism

Detailed explanation of MySQL's FreeList mechanism

1. Introduction

After MySQL is started, BufferPool will be initialized. Before you perform any query operations, the cache pages in BufferPool are blocks of empty memory, which have not been used and no data is stored in them.

And you also know that the cache page it points to can be directly and uniquely found through the description information of the cache page.

Have you ever thought about which buffer page the data page we read from the disk should be placed in?

This problem brings up the Free List.

2. Free List

In fact, Free List is a bidirectional linked list organized in Buffer Pool based on cache page description information. In other words, each node in the Free List is the description information corresponding to the cache page. And the specified cache page (cache page) can be found through the description information

The original intention of InnoDB designing Free List is to solve the above problems.

If no data is stored in this cache page, its corresponding description information will be maintained in the Free List. At this time, when you want to put a data page read from the disk into the cache page, you must first find a node from the Free List (all nodes in the Free List will point to a cache page that has never been used), and then you can put the data page you read into the cache page pointed to by the node.

Corresponding: After data is put into the data page. Its corresponding description information block will be removed from the Free List.

3. How to determine whether the data page is in the cache?

Do you wonder how MySQL knows whether the data page just read is in the cache page?

The implementation of this function relies on another data structure: hash table

key = tablespace number + data page number

value = cache page address

If it exists in the hash table, it means that the data page already exists in the Buffer Pool, and the cache page in the Buffer Pool is used first. I believe you can definitely guess why the cache pages in the Buffer Pool are used first! First, random disk IO is avoided. Second, the data in the cache page may be dirty data that has been modified.

The above is a detailed explanation of MySQL's FreeList mechanism. For more information about MySQL's FreeList mechanism, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Installation and configuration of MySQL 5.6 under Windows with screenshots and detailed instructions
  • Usage instructions for the Mysql string interception function SUBSTRING
  • MySQL user creation and authorization method
  • mysql add index mysql how to create index
  • Super detailed analysis of mysql left join, right join, inner join usage
  • Usage of replace in mySQL
  • Several ways to check the version number of Mysql
  • Mysql command line import sql data
  • How to view or modify the root password of MySQL if it is forgotten (with pictures and text)
  • How to enable remote connection to MySQL database

<<:  Detailed explanation of how to use Docker to build a simple Java development and compilation environment

>>:  In-depth study of JavaScript array deduplication problem

Recommend

MySQL green decompression version installation and configuration steps

Steps: 1. Install MySQL database 1. Download the ...

How to uninstall Linux's native openjdk and install sun jdk

See: https://www.jb51.net/article/112612.htm Chec...

How to set list style attributes in CSS (just read this article)

List style properties There are 2 types of lists ...

Centos7 install mysql5.6.29 shell script

This article shares the shell script of mysql5.6....

13 Most Frequently Asked Vue Modifiers in Interviews

Table of contents 1. lazy 2.trim 3.number 4.stop ...

Install three or more tomcats under Linux system (detailed steps)

If you want to install multiple tomcats, you must...

Vue routing to implement login interception

Table of contents 1. Overview 2. Routing Navigati...

Detailed explanation of jQuery chain calls

Table of contents Chain calls A small case Chain ...

Linux firewall iptables detailed introduction, configuration method and case

1.1 Introduction to iptables firewall Netfilter/I...

Detailed steps for implementing timeout status monitoring in Apache FlinkCEP

CEP - Complex Event Processing. The payment has n...

How to lock a virtual console session on Linux

When you are working on a shared system, you prob...

Tips for writing concise React components

Table of contents Avoid using the spread operator...