当前位置:网站首页>InnoDB storage structure of MySQL
InnoDB storage structure of MySQL
2022-08-05 12:01:00 【ziye cotyledons】

This picture is the memory structure diagram officially provided by MySQL version 5.7
Memory Structure
Buffer Pool
- Innodb_buffer_pool_size setting size in production:
- If MySQL is deployed on an independent server, it is recommended to set it to 80%.Otherwise, set it to 80%~90% of the remaining memory
- View the command show variables like '%innodb_buffer%';
Change Buffer Write Buffer
- By default, it occupies 25% of the space of Buffer_pool, and supports a maximum of 50%. It can be adjusted according to the business. If there is more writing and less reading, it can be appropriately increased.-> innodb_change_buffer_max_size
- View command: show variables like '%innodb_change_buffer_max_size%';
- Set command: set global innodb_change_buffer_max_size = 30;
- When updating a piece of data, the data exists in the Buffer Pool and can be modified directly in the Buffer Pool, one memory operation.If the data does not exist in the Buffer Pool (misses), a memory operation will be performed directly in the Change Buffer. When the next query is made, the data will be read from the disk first, and then the data will be read from the Change Buffer for merging, and finallyLoad into the Buffer Pool.
- Change Buffer, only for non-unique index pages.
- Because if the index is set to be unique, the InnoDB mechanism must perform a uniqueness check when modifying, that is to say, the disk must be queried and an IO operation must be performed.At this time, the data will be directly queried into the Buffer Pool, and then modified in the buffer pool, and the Change Buffer operation will not be performed.
Log Buffer
- Query command:
- show variables like '%innodb_log%';
- View Log Buffer size and disk log file size and number
- The default Log Buffer size is 16MB
- The default disk single log file size is 48MB, and the number is 2
- View Log Buffer size and disk log file size and number
- The command to query the behavior of writing files and flashing disks:
- show variables like '%innodb_flush_log%';
- Write file refers to the process of writing Log Buffer to Operating System Cache (OS Cache)
- Brushing refers to the process of writing OS Cache to disk
- innodb_flush_log_at_trx_commit
- 0: Perform log file writing and disk flushing operations every 1 second, and data will be lost for up to 1 second
- 1: The transaction is committed, the log is written and the disk is flushed immediately, the data is not lost, but the IO operation is performed frequently (default is 1)
- 2: The transaction is committed, the log operation is written immediately, and the disk flush operation is performed every 1 second
disk structure
System Tablespace
- View command: show variables like '%innodb_data_file_path%';
- ibdata1:12M:autoextend refers to the file name: ibdata1, size 12M, autoextend
- InnoDB Data Dictionary data dictionary
- Consists of internal system tables, used to store metadata
- Doublewrite Buffer Double write buffer
- Before the Buffer Pool actually writes to other tables, it first writes the dirty pages in the page page to the double-write buffer.There are two functions, one is to improve the writing speed, and the other is to retrieve lost data from the double write buffer in the event of an accident, so as to achieve double insurance.Double write buffer on by default
- Related commands:
- Check if it is enabled: show variables like '%innodb_doublewrite%';
- View the flushing strategy: show variables like '%innodb_flush_method%';
- The default value is NULL
- It is recommended to set O_DIRECT under Unix system to improve the efficiency of flashing
- Undo Logs
- There are multiple undo_0x files in Undo Tablespaces. Before the transaction is started, the original data that has not been modified is backed up to roll back the transaction in unexpected situations.
- Redo Log redo log
- A disk-based data structure for incomplete transaction write data during crash recovery. MySQL writes to redo log files in a round-robin fashion.Redo log files
The default is two files, a single 48M.
- A disk-based data structure for incomplete transaction write data during crash recovery. MySQL writes to redo log files in a round-robin fashion.Redo log files
Other chapters ->Jump
end...边栏推荐
- 2022.08.01_每日一题
- Mysql8基础知识
- 797. 差分
- 2021 RoboCom World Robot Developers Competition - Higher Vocational Group (Final)
- 对于聚合物聚乙二醇PEG大家了解多少了?以及在生活中的应用
- The importance of parameter naming, remember a JDBC parameter conflict
- [Supply Chain·Case] What did the top ten retailers in the world do under the influence of the epidemic?
- Grid Infrastructure Installation Fails with Error
- The memory problem is difficult to locate, that's because you don't use ASAN
- 什么是缓冲区(buffer),什么是缓存(cache)
猜你喜欢

《Grandmaster level in StarCraft II using multi-agent reinforcement learning》翻译

KVM虚拟化技术的-NUMA技术和应用

C语言例题-打印日历

Quick Check of OGC WebGIS Common Service Standards (WMS/WMTS/TMS/WFS)

isn't it?Is there anyone who can't locate the slow query problem of MySQL online?

KVM virtualization technology-NUMA technology and application

No developers, received a job to develop an IoT system, do you want to do it?

STM32H743IIT6 study notes 01 - CubeMX new project file

尚硅谷-JVM-内存和垃圾回收篇(P1~P203)

详细剖析 Redis 三种集群策略
随机推荐
SonarQube即将亮相第十八届GOPS全球运维大会
Food and Beverage Industry B2B Mall System: Accelerate the digital transformation of the industry and improve the transaction efficiency of the B2B platform
797. 差分
sentinel介绍和使用
该不该将单体架构迁移到微服务?
内存问题难定位,那是因为你没用ASAN
C language classic examples - find the largest number in a series of numbers
Official release 2022 Nanjing Zhibo Expo is scheduled to be held in Xinzhuang National Exhibition in October
60行从零开始自己动手写FutureTask是什么体验?
学习用于视觉跟踪的深度紧凑图像表示
冬日里,28℃的爱情
女人是这个世界上最美丽的生命
Go Quick Start Guide: Basic Types
2022.08.01_每日一题
MySQL之InnoDB线程模型
A woman is the most beautiful life in the world
Exploration and practice of transaction link under multi-service mode
2022 CCF International AIOps Challenge Finals and AIOps Seminar Registration Open
Object中的方法
Small household appliance industry supply chain collaborative management system: help enterprises break through market competition and strengthen the rapid response capability of the supply chain