Try
↑ ↓ move↵ openesc close

Curriculum · Module 07, Storage Engines

Lesson 3 · 7 topics · 34 min · Intermediate · 0/7 done

Indexes and Bloom filters

Secondary indexes make reads cheap and writes dear. A Bloom filter spends a few bits per key to skip files that cannot hold the key.

What each topic covers

  • Without an index, a query by any column but the key scans the whole table. With one, it reads a few pages.
  • How an index points back at rows, and how a bit array answers "maybe" or "no" about a key.
  • Fill a Bloom filter and compare measured false positives with the formula, then add secondary indexes and watch insert cost.
  • An index makes reads cheap by making every insert touch another tree, and the cost grows with the number of indexes.
  • More bits buy fewer false positives with sharply falling returns, and the hash count has a best value.
  • A filter guards one-key lookups, helps most on misses, and cannot answer ranges or deletes.
  • Three quick checks on filter errors, the hash count and the write cost of an index, with the sources behind the lesson.

Topics

  1. 1Finding one row without reading them all3 min
  2. 2Secondary indexes and Bloom filters6 min
  3. 3Tune a filter and add indexes8 min
  4. 4Each index is a tax on every write4 min
  5. 5Bits per key against false positives5 min
  6. 6Where filters help and where they do not4 min
  7. 7False positives, hashes and index cost4 min

Practise this lesson

8 interview questions on indexes and filters, with worked answers and sources.

Practise these

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