← Lessons

quiz vs the machine

Platinum1740

Databases

The Read Path and Write Path

Tracing what happens inside the engine on each operation.

5 min read · advanced · beat Platinum to climb

Two Journeys

Every database engine has a write path that durably records changes and a read path that serves queries. Understanding both explains latency and durability behavior.

The Write Path

A write first appends to the write ahead log for durability, then updates an in memory buffer. Once the log entry is flushed the change is safe even if the server crashes, because recovery replays the log. The actual data pages are written to disk later by a background flush.

The Read Path

A read first checks the buffer cache or memtable in memory. On a hit it returns immediately. On a miss it loads pages from disk, which is far slower, then caches them for next time. In an LSM engine the read may also consult several sorted files and a bloom filter to skip files that cannot hold the key.

Key idea

The write path logs for durability before updating memory and flushing pages later, while the read path serves from cache and only touches disk on a miss.

Check yourself

Answer to earn rating on the learn ladder.

1. What does the write path do first for durability?

2. What happens on a read cache miss?

3. What helps an LSM read skip files that cannot hold a key?