liveBook · Manning

Write amplification

As explained in Crack Any Codebase with AI

Write amplification is the increase in physical write work caused when one logical data change must update multiple stored structures such as indexes.

Write amplification measures how much physical write work a logical change triggers. Each index is a sorted copy of selected columns, so inserting a row writes the main table plus every index; updating an indexed column pays the same cost. section 7.6

Booking table versus audit log

A Booking table with eight indexes can turn one INSERT into nine disk writes. That trade-off may be sensible when bookings are read constantly and created rarely, but copying it onto an append-only audit log makes every write nine times slower for an infrequent search. section 7.6

Use these questions when reviewing a schema:

  • How many indexes does each INSERT or indexed UPDATE maintain? section 7.6
  • Does the read frequency justify the write penalty? section 7.6
  • Are foreign keys indexed, and will deletes or newer columns create hidden scaling costs? section 7.6
@@index([startTime, endTime, status])
@@index([userId, status, startTime])
@@index([userId, endTime])
@@index([eventTypeId, status])
@@index([fromReschedule])
@@index([userId, createdAt])

Inspect the concrete index definitions and compare their covered columns with the application's common filter shapes. section 7.6

How Crack Any Codebase with AI covers it

How deep it goes
Explains the physical write mechanism, quantifies a nine-write example, and stops short of storage-engine internals.
Examples
Uses Cal.com's Booking table, its eight indexes, and an append-only audit-log comparison.
What it assumes
Assumes basic familiarity with tables, rows, columns, indexes, and foreign keys while defining their operational trade-offs.
What you can do after
Evaluate index sets by estimating write penalties against read frequency and checking foreign-key coverage.
How it connects
Connects indexes with query patterns, foreign keys, soft deletes, schema design, and read-write trade-offs.

Also explained in

Compare how 2 books explain write amplification →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Crack Any Codebase with AI. The section links point to the parts of the book it draws on.