A B-tree is the workhorse index behind most databases and filesystems. When a record changes, the tree has to update a page, and there are two philosophies about how to do it. In-place designs overwrite the page in its existing location, protecting the change with a write-ahead log. Copy-on-write designs write a brand new page elsewhere and redirect the parent pointer to it. Both keep the tree correct, but they lead to very different behaviour under crashes, snapshots and heavy writes.
An in-place B-tree rewrites a page at its fixed address and relies on a write-ahead log for crash recovery, while a copy-on-write B-tree never overwrites a live page — it allocates a new one and atomically swaps the root, making old versions readable as snapshots.
The choice is not about which tree searches faster; both find a key in the same number of comparisons. It is about what happens after a write, a crash or a backup.
Part One: What each approach actually does
An in-place B-tree treats each page as a fixed slot on disk. Updating a record means reading the page, modifying it in memory and writing it back to the same block address. That is efficient in space — the tree stays compact and only the changed page is rewritten. The danger is a crash halfway through: the page on disk might be half old and half new, leaving the tree corrupt.
The standard fix is a write-ahead log. Before changing a page, the system records the intended change in an append-only log and flushes it. If a crash occurs, recovery replays the log to finish or undo incomplete updates. This works extremely well and is the foundation of most relational databases. The cost is that every write is paid for twice — once to the log, once to the page — and recovery has to process the log at startup.
A copy-on-write B-tree never modifies a page in place. To change a leaf, it writes a new leaf to a free block, then a new parent pointing to it, and so on up to the root. A single atomic write of the root pointer switches the whole tree to the new version in one moment. Because old pages are never overwritten, a crash simply leaves the old root valid; there is no partial update to repair and no write-ahead log needed.
Copy-on-write turns a page update into a chain of new allocations from the leaf to the root, so a single small record change can write several pages, but it makes crash consistency almost automatic and snapshots essentially free.
Part Two: The mechanism that separates them
The mechanism is how a consistent version is identified. In-place designs keep one physical tree and use a log to describe recent changes, so consistency is a property of the log replay. Copy-on-write designs keep many physical versions and use the root pointer to select the current one, so consistency is a property of one atomic pointer write.
That difference cascades. Snapshots become trivial with copy-on-write: keep the old root pointer and you can read the tree exactly as it was, while writes proceed to new pages. This is why filesystems like Btrfs and ZFS can take instantaneous snapshots and roll back. With an in-place tree, a snapshot requires either copying the whole tree or maintaining a more complex multi-version scheme.
The write amplification runs the other way. A copy-on-write update touches every level from the changed leaf to the root, so a tiny change may write four or five pages. In-place updates touch one page plus the log. On write-heavy workloads that gap can dominate performance and wear out flash storage sooner. Copy-on-write filesystems mitigate this with techniques like logging and delayed allocation, but the fundamental extra traffic remains.
A second mechanism is space reclamation. Old pages in a copy-on-write tree cannot be freed immediately because a snapshot might still reference them. The system must track which versions are still in use and reclaim pages only when no root points to them. In-place designs avoid this because there is only ever one live version of a page.
Part Three: Where you notice it
Where you feel it is in backups and recovery time. A filesystem with copy-on-write snapshots can create a restore point before a risky update and roll back in seconds if something breaks — the kind of feature that saves a laptop after a bad driver install. The same operation on an in-place filesystem may require copying large amounts of data or relying on a slower, log-based restore.
On a busy transactional database, the picture reverses. Thousands of small row updates per second generate far less write traffic with in-place pages plus a well-tuned log than with copy-on-write, and storage devices last longer. That is why most OLTP databases still use in-place B-trees with write-ahead logging, while snapshot-heavy filesystems favour copy-on-write.
The market reflects the split. Transactional engines optimise for write throughput and mature recovery tooling; modern filesystems optimise for data integrity, snapshots and checksums. Both are multi-billion dollar foundations of computing, and each chose the trade that fits its workload.
In-place trees minimise write traffic and lean on a log for safety; copy-on-write trees minimise crash-recovery complexity and make versioning cheap — the right one depends on whether you fear write amplification or value snapshots.
There is a middle path. Some systems use copy-on-write at the filesystem level over an in-place database, getting snapshots of the file while the database handles its own logging. Others use in-place pages with periodic full snapshots. The boundary is a design choice, not a law.
What is actually transferable
The transferable idea is that crash consistency can be achieved either by recording intentions before you act or by never destroying the old state. Those are the two fundamental strategies, and almost every durable system picks one or blends them.
The second lesson is that a cheap operation today can create an expensive cleanup tomorrow. Copy-on-write makes writes safe but shifts the cost to reclamation; logging makes writes compact but shifts the cost to recovery. Where the cost lands matters as much as its size.
An in-place tree and a copy-on-write tree can store the same index and answer the same query, but one rewrites and remembers, while the other preserves and replaces, and your workload decides which habit is affordable.
SOL: HCqPmPJM3NVtS6YrmVaTZYnuP8XZ2PFgQZKT94VK1LkS
Creating this takes real effort — thank you for the support.