下邊這段話主要描寫了innodb如何來保障可恢復,和減少fsync的數量的

bulletming發表於2019-02-12

12.5.14.1. InnoDB Disk I/O

InnoDB uses simulated asynchronous disk I/O: InnoDB creates a number of threads to take care of I/O operations, such as read-ahead.

There are two read-ahead heuristics(啟發式) in InnoDB:

  • In sequential read-ahead, if InnoDB notices that the access pattern to a segment in the tablespace is sequential, it posts in advance a batch of reads of database pages to the I/O system. (innodb注意到大批次的順序讀相應,會事先去批次讀資料)

  • In random read-ahead, if InnoDB notices that some area in a tablespace seems to be in the process of being fully read into the buffer pool, it posts the remaining reads to the I/O system. (不懂)

InnoDB uses a novel file flush technique called doublewrite. It adds safety to recovery following an operating system crash or a power outage, and improves performance on most varieties of Unix by reducing the need for fsync() operations.

Doublewrite means that before writing pages to a data file, InnoDB first writes them to a contiguous tablespace area(比較覺得這個就是log_buffer,記錄到連續的空間意味著將原本的隨機寫先透過順序寫儲存起來) called the doublewrite buffer. Only after the write and the flush to the doublewrite buffer has completed does InnoDB write the pages to their proper positions in the data file(寫資料前要先寫doublewrite buffer). If the operating system crashes in the middle of a page write, InnoDB can later find a good copy of the page from the doublewrite buffer during recovery.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/82392/viewspace-158557/,如需轉載,請註明出處,否則將追究法律責任。

相關文章