liveBook · Manning

Write penalty

As explained in Grokking Software Architecture

A write penalty is the additional latency incurred when database modifications require indexes to be maintained.

Indexes help a database find records faster, but they add work whenever data changes. That extra latency is the write penalty: each INSERT, UPDATE, or DELETE may require the database to maintain its indexes. section 8.5.1

Filing paperwork

With no index, filing a document is like tossing it into one bin. With indexes, you also file copies in folders such as “By Date,” “By Author,” and “By Subject.” Finding a document gets easier, but filing takes longer. section 8.5.1

A table with zero indexes needs one write to store a row. With five indexes, the database also performs five index-maintenance operations. More indexes can speed up reads, but make writes heavier. section 8.5.1

Figure 8.11 The Tradeoff: Indexes speed up reads (finding the file) but slow down writes (you have to file the paper in multiple places).

Use the filing-cabinet comparison to see how indexes trade faster lookups for slower writes. section 8.5.1

Treat indexes as a tradeoff, not a free speed boost: choose them to help reads that need it, while accounting for the extra work on every data modification. section 8.10

How Grokking Software Architecture covers it

How deep it goes
Defines the latency cost, illustrates it with filing, and compares write work for tables with zero and five indexes.
Examples
Uses filing documents by date, author, and subject, plus a comparison of writes with zero versus five indexes.
What you can do after
Evaluate whether faster indexed reads justify additional maintenance on writes.
How it connects
Connects database indexes and B-trees to read performance and INSERT, UPDATE, and DELETE operations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.