MySQL之change buffer和buffer pool

2020 first article, delayed two weeks time than expected, the sudden outbreak people know what to do, should be no Spring Festival this year, the same as it, hopefully as soon as the outbreak can last, everything back to normal as soon as possible!

Refresh and review MySQL knowledge, it is mainly re looking mind mapping previously recorded, then < > And <<architect road>> to review and supplement, so the following are not impress many in the form of a screenshot.

buffer pool

What InnoDB buffer pool cache? What is the use?
Cache table data and index data, the data is loaded on the disk to the buffer pool to avoid every access disk IO, play a role in accelerating access

to sum up:

  1. Buffer pool (buffer pool) is a common mechanism to reduce disk access;
  2. Page buffer pool typically (page) in units of cache data;
  3. Common buffer pool management algorithm is LRU, memcache, OS, InnoDB uses this algorithm;
  4. InnoDB is optimized for ordinary LRU:
    • The pool is divided into the old generation and the new generation, into the buffer pool page, preferential access to the old generation, the page is accessed, before entering the new generation, in order to solve the problem of pre-reading failure
    • Page is accessed, and the Older Generation stay longer than a configurable threshold, before entering the new generation, in order to solve the bulk data access, a lot of heat out of the issue of data

change buffer

change buffer InnoDB is a write buffer, the write operation aims to reduce disk IO
usage scenarios

  • Suitable
    for Write Once Read Many small businesses, the probability of a page immediately after finished access to relatively small, this time using the best effect change buffer. This business model is common bills class, class of system log
  • Not suitable for
    assuming that a business update mode is done immediately after writing queries, even if the conditions are satisfied, the first update record in change buffer, but after due immediately to access the data page, it will immediately trigger the merge process. In this way the number of random access IO will not be reduced, but increased the maintenance costs of change buffer. So, for this business model is, change buffer but played side effects

Sample

For example, to modify the page number for the index page 40

1. this page buffer pool(缓冲池)in

2. This page is notbuffer pool(缓冲池) in


The above steps are

  1. This operation is recorded in the change buffer, the first memory operation
  2. Write redo log, a sequential write disk operation


Note that the above reading process, just before the recording operation in the change buffer, buffer poll and did not, therefore need to be read from disk, and then do the merge read operation from the change buffer, the buffer pool to put it back in

Why change buffer unique index can not be used?

For the update operation

  • Unique index (not available)
    • In memory: direct judgment there is no conflict, no conflict updates directly to memory without using the change buuffer.
    • Not in memory: the data page is read into memory (need to read data from the disk judge), judge that there is no conflict without the use of change buffer.
  • General index (can be used)
    • In memory: direct update, do not use change buffer
    • Not in memory: update records directly to the end of the change buffer. Use change buffer

Relevant information

Guess you like

Origin www.cnblogs.com/zlone/p/12285994.html