Configuring innodb_flush_method system variable for InnoDB performance

The innodb_flush_method system variable in MySQL allows you to configure the method used for flushing data to disk in InnoDB. This variable affects the durability and performance characteristics of the InnoDB storage engine. Here are some commonly used options and their implications:

  1. fsync:

This is the default value for innodb_flush_method. It uses the operating system’s fsync() function to flush data to disk. This method provides a high level of data durability but can have an impact on performance due to disk I/O latency. It ensures that data is written to disk before a transaction is considered committed.

  1. O_DIRECT:

This option bypasses the operating system’s buffer cache and writes data directly to disk. It can improve write performance by eliminating the overhead of double buffering (buffer cache and InnoDB buffer pool). However, it may require a file system that supports direct I/O, and not all operating systems or file systems provide this support.

  1. O_DSYNC:

Similar to O_DIRECT, this option bypasses the operating system’s buffer cache but allows for the synchronization of metadata. It provides a balance between durability and performance. It can be an effective option if your file system supports O_DSYNC but not O_DIRECT.

It’s important to note that the availability and behavior of these options can vary depending on the operating system and file system being used. It’s recommended to consult the MySQL documentation and the documentation of your specific operating system and file system to understand the supported options and their implications.

When selecting the appropriate innodb_flush_method value for your environment, consider the trade-off between data durability and performance. If data integrity is critical, using fsync or a method that ensures synchronous writes is recommended. If write performance is a priority and you have a reliable backup and recovery strategy in place, options like O_DIRECT or O_DSYNC can be considered.

To set the innodb_flush_method variable, you can add it to the MySQL configuration file (e.g., my.cnf) under the [mysqld] section:


After making changes to the configuration file, restart the MySQL service for the new configuration to take effect.

Remember to carefully test and monitor the performance and stability of your system after adjusting the innodb_flush_method variable to ensure it meets your specific requirements and provides the desired balance between durability and performance.

About Shiv Iyer 455 Articles
Open Source Database Systems Engineer with a deep understanding of Optimizer Internals, Performance Engineering, Scalability and Data SRE. Shiv currently is the Founder, Investor, Board Member and CEO of multiple Database Systems Infrastructure Operations companies in the Transaction Processing Computing and ColumnStores ecosystem. He is also a frequent speaker in open source software conferences globally.