The idea to keep with you
If disk I/O or compaction stalls threaten tail latency, use HyperLogLog for COUNT(DISTINCT) and Count-Min Sketch (+ min-heap) for Top-K heavy hitters whenever O(N) HashSets or HashMaps would OOM.
TL;DR30-second simplified summary▾
HyperLogLog estimates billion-scale distinct counts in O(2^p) fixed bytes (~12 KB at p=14 for 0.81% error) via leading-zero registers and harmonic-mean averaging, while Count-Min Sketch bounds frequencies in O(d*w) counters. Both merge across shards in O(1) network size and pair with a size-K min-heap for heavy hitters.
Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Bloom Filters, Counting Bloom & Cuckoo Filters
Bloom filters answer set membership in O(k) bit probes using ~10 bits per key at a 1% false-positive rate with zero false negatives, while Cuckoo filters store compact fingerprints in 2-choice hash buckets to support safe item deletion and better CPU cache loc...
Full walkthrough · 7 stages
01
L4 · FUNDAMENTALS
.
02
L4 · FUNDAMENTALS
.
03
L5 · APPLIED DESIGN
.
04
L5 · APPLIED DESIGN
.
05
L6 · SCALE & TRADE-OFFS
.
06
L6 · SCALE & TRADE-OFFS
.
07
L7 · STAFF / PRINCIPAL
.
Practice · Explain the consequences
Practice: Make the trade-off yourself.
Question 1 of 3
Score: 0/3When querying a Count-Min Sketch for key `x`, why do we take the MINIMUM across the `d` hash rows instead of the average?
Recommended Learning Flow