Grdb using SQLite's Wal-mode Wal full name is the write Ahead Logging, which is a mechanism for implementing atomic transactions in SQLite. This mode was introduced from the SQLite 3.7.0 release. Before that, SQLite uses the rollback journal mechanism to implement atomic transactions. In the rollback journal mechanism, when the data needs to be modified, the modified data is first backed up, and then the data of the database is modified. If the transaction succeeds, the backup data is deleted, and if the transaction fails, the backup data is restored. The disadvantage of this mechanism is that it is frequently read and written and cannot be read. The Wal mode works like its name, writing a log file before writing to the database. This log file is named Wal file. When the transaction succeeds, the modified content remains in the file. When the transaction fails, it is removed from this file. When the record of the Wal file accumulates to a certain number, it is written to the database once. If the database is read, it is read from the Wal before the database file is read. In this way, the write operation does not affect the read operation, thereby increasing efficiency. Grdb directly supports the WAL mode. When a developer uses Databasepool to establish a database connection, the default is to use the Wal mode, which is not used if a connection is established using Databasequeue. If there are too many accumulated data in the Wal, writing to the database can result in degraded database performance, so avoid Wal accumulating too much data.
Grdb using SQLite's Wal mode