Thursday 18 July 2013

MySQL innodb_flush_log_at_trx_commit parameter

Today engineer try to import 3 millions data from dump file, it's very very slow, check the configuration, innodb_buffer_pool_size only set to 128M, reset to 4G and test again , still very slow, suddenly remember the parameter innodb_flush_log_at_trx_commit, the MySQL server using the default value = 1, set this parameter to 2, import become very fast.

Here paste the description from MySQL website

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 1, the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file. 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. Note that the once-per-second flushing is not 100% guaranteed to happen every second, due to process scheduling issues.
The default value of this variable is 1 (prior to MySQL 4.0.13, the default is 0).
A value of 1 is required for ACID compliance. You can achieve better performance by setting the value different from 1, but then you can lose at most one second worth of transactions in a crash. With a value of 0, any mysqld process crash can erase the last second of transactions. With a value of 2, then only an operating system crash or a power outage can erase the last second of transactions. However, InnoDB's crash recovery is not affected and thus crash recovery does work regardless of the value.

No comments:

Post a Comment