logo

WAL vs rollback journal

Last Updated: 2022-02-12

There are 2 opposite ways to rollback the database to a previous state: "Rollback Journal" and "Write-ahead log".

Rollback Journal

  • make a copy of the original database content and save it in a separate file, i.e. rollback journal, then write the new values into database directly.
  • A COMMIT occurs when the rollback journal is deleted.
  • rollback: copy the content in rollback journal back to database.

Write-ahead-log

  • changes are appended to the write-ahead log file.
  • A COMMIT occurs when a special "commit" record is appended to the WAL. (the original database may not be altered!)
  • multiple transactions can be committed before a "checkpoint", when the database will be updated according to write-ahead log.