当前位置:网站首页>MySQL combat optimization expert 12 what does the memory data structure buffer pool look like?
MySQL combat optimization expert 12 what does the memory data structure buffer pool look like?
2022-07-06 10:07:00 【Office template library material frog】
1、 How to configure your Buffer Pool Size ?
First let's take a look , How should we configure your Buffer Pool How big is it ?
because Buffer Pool The essence is actually a memory component of the database , You can understand it as a piece of memory data structure , So this memory data structure must be Have a certain size , It can't be infinite .
This Buffer Pool By default 128MB, It's still a little small , Under the actual production environment, we can completely Buffer Pool Adjustment .
For example, if our database is 16 nucleus 32G Machine , Then you can give Buffer Pool Assigned 2GB Of memory , Just use the following configuration .
[server]
innodb_buffer_pool_size = 2147483648
If some friends don't know where the configuration file of the database is and how to modify its configuration , The suggestion is to search some on the Internet first MySQL Go to the introductory materials have a look , In fact, this is the most basic and simple .
Let's first look at the following figure , There are pictures in the database Buffer Pool Memory components .
2、 Data pages :MySQL A unit of data abstracted from
Let's move on to the next question , Suppose that there must be a memory area in our database now Buffer Pool 了 , So how do we put our data in BufferPool Medium ?
We all know that the core data model of the database is the table + Field + The concept of line , In other words, we all know that there are tables in the database , A watch has many words paragraph , Then there are many rows of data in a table , Each row of data has its own field value . So we think our data is placed line by line in Buffer Pool Inside Do you ?
This is obviously not , actually MySQL The concept of a data page is abstracted from the data , He put many rows of data in one data page , That is to say, I There are many data pages in your disk file , There are many lines of data in each page , As shown in the figure below .
So in fact, suppose we want to update a row of data , At this time, the database will find the data page where this row of data is located , Then from the disk file, put the data page where this line of data is located Load directly into Buffer Pool In go to
in other words ,Buffer Pool There are data pages stored one by one , Here's the picture .
3、 Data pages on disk and Buffer Pool How do the cached pages in correspond ?
In fact, by default , The size of the data pages stored on the disk is 16KB, in other words , One page of data contains 16KB The content of .
and Buffer Pool One data page after another stored in , We usually call it cache page , Because after all Buffer Pool It's a buffer pool , The data inside is from the magnetic Disk cache to memory .
and Buffer Pool By default , The size of a cache page corresponds to the size of a data page on the disk , All are 16KB.
So let's look at the following figure , I give the Buffer Pool Marked out his memory size , Suppose he is 128MB Well , Then the size of the data page is 16KB.
4、 What is the description information corresponding to the cache page ?
Then we need to understand the next concept , For each cached page , He actually has a descriptive message , This descriptive information can generally be considered to describe this slow Page saved
For example, it contains some of the following things : The table space to which this data page belongs 、 The number of the data page 、 This cache page is in Buffer Pool The address in and some other miscellaneous Eight things .
Each cache page corresponds to a description , The description information itself is also a piece of data , stay Buffer Pool in , The description data of each cache page is placed at the top , Then each cache page is placed at the back
So now let's look at the following figure ,Buffer Pool It actually looks like this .
And here we should pay attention to one thing ,Buffer Pool The description data in is roughly equivalent to the size of the cache page 5% about , That is, each description data is about 800 A word Section size , Then suppose you set buffer pool Size is 128MB, actually Buffer Pool The real final size will exceed some , There might be a 130 many MB The appearance of , Because it also stores the description data of each cache page .
5、 Today's question
Today I want to leave you to think about a problem , Is the problem of memory fragmentation
You can imagine , about Buffer Pool for , It will store many cache pages and corresponding description data , So suppose Buffer Pool In the memory It's all used up , There is not enough memory left to store cached pages and description data , here Buffer Pool Is there no memory in it ? Still say Buffer
Pool There will be some memory fragments left in the ?
If you think Buffer Pool If there are memory fragments in the , So what do you think should be done to minimize Buffer Pool Memory fragments in ?
边栏推荐
猜你喜欢
14 医疗挂号系统_【阿里云OSS、用户认证与就诊人】
C miscellaneous lecture continued
Write your own CPU Chapter 10 - learning notes
Which is the better prospect for mechanical engineer or Electrical Engineer?
MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
C杂讲 文件 续讲
14 medical registration system_ [Alibaba cloud OSS, user authentication and patient]
Some thoughts on the study of 51 single chip microcomputer
jar运行报错no main manifest attribute
随机推荐
MySQL ERROR 1040: Too many connections
颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
14 medical registration system_ [Alibaba cloud OSS, user authentication and patient]
cmooc互联网+教育
嵌入式開發中的防禦性C語言編程
Nc29 search in two-dimensional array
docker MySQL解决时区问题
MySQL ERROR 1040: Too many connections
Southwest University: Hu hang - Analysis on learning behavior and learning effect
MySQL实战优化高手09 生产经验:如何为生产环境中的数据库部署监控系统?
NLP routes and resources
Zsh configuration file
在CANoe中通过Panel面板控制Test Module 运行(高级)
Listen to my advice and learn according to this embedded curriculum content and curriculum system
Redis集群方案应该怎么做?都有哪些方案?
CANoe不能自动识别串口号?那就封装个DLL让它必须行
MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
Control the operation of the test module through the panel in canoe (primary)
Single chip microcomputer realizes modular programming: Thinking + example + system tutorial (the degree of practicality is appalling)
Simple solution to phpjm encryption problem free phpjm decryption tool