AlgoViz

Introduction to storage

easy 24 min

How a database keeps data: pages on disk, a buffer pool of pages in memory, indexes that find the right page, and a write-ahead log that makes a commit survive a crash.

Where it shows up

The same pattern appears across everyday software.

  • PostgreSQL

    Stores every table and index as an array of 8 KB pages and flushes its WAL at commit. A checkpoint starts every 5 minutes by default, or sooner when the log is about to reach its limit.

  • MySQL InnoDB

    Uses 16 KB pages, a buffer pool with a variation of LRU, a redo log and a doublewrite buffer that protects against half-written pages.

  • SQLite

    A whole database in one file of 4 KB pages. The default is a rollback journal; its WAL mode appends changes to a separate file.

  • MongoDB

    Its WiredTiger engine combines checkpoints with a journal. By default the journal is synced every 100 milliseconds, and when a write asks for it.

  • Cassandra

    Appends each write to a commit log and keeps it in a memtable. The commit log is synced periodically by default, every 10 seconds, so a power cut on one node can lose that node's last seconds.

  • Oracle Database

    Calls its log the redo log and describes it as the most crucial structure for recovery.