4 change buffer
4.1 Basic concepts
change buffer is a special data structure that caches changes to secondary index pages when those pages are not in the buffer pool. Buffer changes that may be caused by INSERT, UPDATE, or DELETE operations (DML) will be merged later when the page is loaded into the buffer pool by other read operations.
Related free learning recommendations: mysql video tutorial
As can be seen in the picture above, the change buffer is used The memory in the buffer pool cannot grow infinitely. The change buffer size can be dynamically set through the parameter innodb_change_buffer_max_size.
For example, if set to 50: the size of the change buffer can only occupy up to 50% of the buffer pool.
When a data page needs to be updated:
When the next query accesses the data page, the data page will be read into the memory, and then the change buffer will be executed with this page related operations. In this way, the correctness of the data logic can be ensured.
change buffer is actually persistent data, that is, it is not only copied in memory, but also written to disk.
4.2 merge
The process of applying the operations in the change buffer to the original data page to obtain the latest results.
4.2.1 Trigger timing
If the update operation can be recorded in the change buffer first to reduce disk reading, the statement execution speed will be significantly improved. And reading data into memory requires occupying the buffer pool, so it can also reduce memory usage and improve memory utilization.
4.3 When to use change buffer
4.4 Applicable Scenarios
Can all scenarios of ordinary indexing be accelerated by using change buffer?
Note that merge is the time when the data is actually updated, and the change buffer mainly caches the recorded change actions. Therefore, before a data page is merged, the more changes the change buffer record has (that is, the more times the data page needs to be updated), the greater the benefit.
More related free learning recommendations: mysql tutorial(Video)
The above is the detailed content of Introducing the change buffer in MySQL Buffer pool. For more information, please follow other related articles on the PHP Chinese website!