Android 9 introduces a special mode of
called Compatibility WAL (write-ahead logging) that allows a database to use
journal_mode=WAL while preserving the behavior of keeping a maximum of one
connection per database.
Compatibility WAL is enabled for an application's database by default unless the application has either:
- Opted-in or out of write-ahead logging by calling
- Explicitly requested journal mode by calling
Enabling the WAL journal mode can lead to a significant improvement in performance and reduction in the amount of writes. For example, on an ext4 filesystem, WAL can lead to a 4x improvement in write speed.
Compatibility WAL is enabled by default and doesn't require any additional implementation.
Disabling Compatibility WAL
To disable the Compatibility WAL mode, overlay the
You may want to disable Compatibility WAL for configurations where the WAL journal mode does not provide a performance advantage over traditional rollback journal modes. For example, on a F2FS filesystem, although SQLite supports atomic writes and the DELETE journal performance is similar to WAL, WAL can increase the amount of writes by 10% to 15%.
To validate the Compatibility WAL mode, run CTS tests from the CtsDatabaseTestCases module. CTS tests will verify the expected behavior when Compatibility WAL is enabled.