问答详情
源自:5-2 MySQL配置文件优化

没听懂innodb_fulsh_log_at_trx_commit 值为0和2的区别是啥

好像都是一秒以后刷新到磁盘,是2会先刷到缓存里么,那0的时候一秒以后直接刷磁盘?

提问者:英宁 2016-02-20 10:17

个回答

  • 大老唐
    2016-12-21 21:16:41
    已采纳

    0和2都是每秒从缓冲区写入文件一次。区别是commit操作时,0不做任何操作,为2 的时候,commit时会把缓冲区内容写入文件。文档上是这么写的:If the value of innodb_flush_log_at_trx_commit is 0, the log buffer is written out to the log file once per second and the flush to disk operation is performed on the log file, but nothing is done at a transaction commit.. When the value is 2, the log buffer is written out to the file at each commit, but the flush to disk operation is not performed on it. However, the flushing on the log file takes place once per second also when the value is 2.

  • 拿拿斯
    2016-02-23 15:53:46

    0是每秒刷一次磁盘,1是每一个事务提交后都要刷一次磁盘,2是提交事务后记录但是不刷盘。