当前位置:网站首页>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 ?
边栏推荐
- [flask] crud addition and query operation of data
- 16 医疗挂号系统_【预约下单】
- NLP routes and resources
- Teach you how to write the first MCU program hand in hand
- Control the operation of the test module through the panel in canoe (primary)
- 17 医疗挂号系统_【微信支付】
- MySQL实战优化高手09 生产经验:如何为生产环境中的数据库部署监控系统?
- Programmation défensive en langage C dans le développement intégré
- Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
- MySQL实战优化高手06 生产经验:互联网公司的生产环境数据库是如何进行性能测试的?
猜你喜欢
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
How can I take a shortcut to learn C language in college
Target detection -- yolov2 paper intensive reading
Southwest University: Hu hang - Analysis on learning behavior and learning effect
MySQL的存储引擎
Mexican SQL manual injection vulnerability test (mongodb database) problem solution
颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
AI的路线和资源
What you have to know about network IO model
随机推荐
The programming ranking list came out in February. Is the result as you expected?
Inject common SQL statement collation
MySQL實戰優化高手08 生產經驗:在數據庫的壓測過程中,如何360度無死角觀察機器性能?
Retention policy of RMAN backup
What you have to know about network IO model
在CANoe中通过Panel面板控制Test Module 运行(高级)
MySQL ERROR 1040: Too many connections
CAPL 脚本对.ini 配置文件的高阶操作
Cmooc Internet + education
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
MySQL实战优化高手10 生产经验:如何为数据库的监控系统部署可视化报表系统?
C杂讲 双向循环链表
15 medical registration system_ [appointment registration]
Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work
安装OpenCV时遇到的几种错误
MySQL ERROR 1040: Too many connections
Preliminary introduction to C miscellaneous lecture document
C miscellaneous two-way circular linked list
寶塔的安裝和flask項目部署
C杂讲 文件 续讲