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

vue-pdf realizes online file preview

This article example shares the specific code of ...

MySQL 5.6.28 installation and configuration tutorial under Linux (Ubuntu)

mysql5.6.28 installation and configuration method...

Detailed explanation of JS browser event model

Table of contents What is an event A Simple Examp...

This article teaches you how to play with CSS combination selectors

CSS combination selectors include various combina...

Implementing a simple calculator based on JavaScript

This article shares the specific code of JavaScri...

Apache Spark 2.0 jobs take a long time to finish when they are finished

Phenomenon When using Apache Spark 2.x, you may e...

Ubuntu 20.04 connects to wifi (2 methods)

I recently installed Ubuntu 20.04 and found that ...

Solution to ERROR 1054 (42S22) when changing password in MySQL 5.7

I have newly installed MySQL 5.7. When I log in, ...

WeChat applet implements simple calculator function

This article shares the specific code for the WeC...

Vue shuttle box realizes up and down movement

This article example shares the specific code for...

Teach you how to insert 1 million records into MySQL in 6 seconds

1. Idea It only took 6 seconds to insert 1,000,00...

Div nested html without iframe

Recently, when doing homework, I needed to nest a ...

Things to note when designing web pages for small-screen mobile devices

The reason is that this type of web page originate...

Ubuntu 20.04 firewall settings simple tutorial (novice)

Preface In today's increasingly convenient In...