一、mysql group commit 的官方定義:
InnoDB, like any other ACID-compliant database engine, flushes the redo log of a transaction before it is committed. InnoDB uses group commit functionality to group multiple such flush requests together to avoid one flush for each commit. With group commit, InnoDB issues a single write to the log file to perform the commit action for multiple user transactions that commit at about the same time, significantly improving throughput.
An?InnoDB
?optimization that performs some low-level I/O operations (log write) once for a set of?commit?operations, rather than flushing and syncing separately for each commit.
參考連接:
https://dev.mysql.com/doc/refman/5.7/en/innodb-performance-group_commit.html
https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_group_commit
?
二、翻譯一下
innodb 和所有支持acid屬性的引擎一樣,提交得以完成的條件是事務相關的redo log 都刷新到了磁盤,innodb 使用組提交
的方式把多個刷新操作組織到一起,這樣就避免為每一個commit發起一個刷新操作,而是多個commit共用一個刷新。
?
三、group commit 的原理:
為了說明innodb group commit的原理,我在這里假設一個有3個事務同時運行
?
a事務從t0 時刻開始運行,到t1時刻完成的操作,t9的時間收到了commit指令
b事務從t1 時刻開始運行,到t2時刻完成的操作,t8的時間收到了commit指令
c事務從t3 時刻開始運行,到t4時刻完成的操作,t5的時間收到了commit指令
?
傳統模式下三個commit對應三次刷新操作,但是在group commit 情況下一次就行了,看圖
?
?
?
----