Count-Min Sketch updates and estimates 00:00:01 Three rows follow the same request stream Can a counter reading five correctly support the answer two? Start with checkout and search requests and three independent hash rows. Each row contains a hundred counters, all initially zero. I define checkout and search as distinct keys, each mapped to one counter per row using different hash functions to minimize overlap. Each event increments one counter in every row, so every request updates three separate positions across the sketch structure. Think of each row as a different crowd sharing numbered lockers. Checkout always uses its own fixed locker in a particular row. Search might share that locker in one row and use a completely different locker in another. 00:00:42 Record two checkout events After two checkout events, each of their three corresponding counters now holds the value two, since both events updated the same positions in all rows. Next, three search events collide with checkout in row one only. The checkout bucket in that row rises from two to five. Its row-two and row-three buckets stay at two. Now when I check checkout, the three row values are five, two, and two, so the sketch reflects an inflated count in one row. To check the arithmetic, write down only the three counters that checkout would read. Search still updates three counters of its own. Two of those writes simply land outside the three counters we are following. 00:01:21 Ask for one frequency estimate I query the three buckets for checkout and take the smallest value, which is two, correctly matching the actual number of checkouts. The row with five includes extra search events due to collision, so selecting it would overcount, but the minimum avoids that error. Here both the second and third rows remain clean for checkout. Their value is two, so two is the minimum. The sketch has recovered the exact count for this particular stream. Notice the distinction between verifying this example and guaranteeing every query. We know two because we kept the original five events for the demonstration. The sketch by itself cannot certify that any one row was clean. 00:01:58 What if every row collides? If all three rows had collisions, every counter could be inflated, but the minimum still gives a safe upper bound on the true count. With nonnegative updates, the estimate never drops below the true frequency because collisions only add to counters, never subtract. If every row has some overcount, taking the minimum may still overestimate. A suitable width and depth reduce probabilistic error under the hashing assumptions. They do not remove every possible collision. Under the usual hash assumptions, more width controls the additive error scale, and more independent rows improve confidence. Set accuracy against the total stream mass and design for counter overflow and the lifetime of the window. 00:02:38 Know the missing operation The sketch only tracks counts for known keys and doesn’t store a full list of all seen endpoints, so I can’t list every unique one. To find heavy endpoints, keep names in a separate candidate structure or derive them from a bounded sample, then query the sketch by name. A counter with a large value has no reversible endpoint label. When merging sketches, I only combine counters that share the same hash functions, row count, and update semantics to preserve accuracy. Merge standard additive sketches only if dimensions, hashes, seeds, counters and event windows agree. Adding the same input partition twice counts it twice. Addition is valuable across independent traffic shards, but it does not deduplicate events.