Try
↑ ↓ move↵ openesc close

Interview prep / Indexes and filters

Senior · Indexes and filters · System design interview question

A table takes thousands of inserts a second and has grown ten indexes over the years. Insert latency is rising. How do you investigate and fix it?

Sketch your own answer first, then compare it with the one below.

A strong answer

Start by measuring which indexes are used. Most databases track how often each index serves a query. An index that nothing reads is pure write cost and can go. Check for redundant ones too, such as an index on a that is covered by one on a and b.

Then look at the write path. Each remaining index adds random page writes and log records per insert. Options are to merge indexes with a composite that serves several queries, to make indexes partial, so they cover only the rows that matter, to move rarely used lookups to a replica or search system, and to batch writes so pages are touched once.

A good answer weighs each index by reads served against write cost, and says to change one thing at a time with before and after measurements.

Sources

Learn it by running it

The indexes and bloom filters lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms