How a Bloom filter knows a name is missing
Eight bits explain when a database can safely skip a lookup.

A database has a sorted file full of usernames. Someone asks for “fern”. Even learning that the name is missing might mean reading part of the file. What if a few bits in memory could tell the database to skip that read? A Bloom filter does exactly that. Sometimes it asks the database to check anyway. The file still gets the final say.
The trick is to keep just enough information to prove absence. To see how little that takes, try building a filter that fits on a scrap of paper.
Eight bits and three names
Draw eight boxes numbered zero through seven. Each box holds a bit, initially zero. Give each name two box numbers. In a real filter, hash functions calculate those numbers from the name. Here are some made-up assignments so you can follow every bit by eye.
name box numbers
elm 1, 4
ash 4, 6
yew 1, 6
fern 2, 4
Insert “elm” by setting boxes one and four to one. Insert “ash” by setting four and six. Box four was already on. Setting it again has no effect. After two insertions, only boxes one, four and six are on. There is no entry holding the letters in either name. There is also no record of which name turned on which bit.
Now look up “fern”. Box four is on, but box two is off. If fern had ever been inserted, its insertion would have turned on box two. You can stop there. Try “yew” instead. Both of its boxes are on, even though nobody inserted it. Elm supplied the first bit and ash supplied the second. This is a false positive. The lookup assembled evidence from two different names.
Why a single zero settles it
There is a short proof behind that first answer. After an insertion, every box required by that key is on. Every later insertion either leaves those boxes alone or sets them to one again. So they stay on for the lifetime of this insert-only filter. Finding even one zero contradicts the claim that this key was inserted. Finding two ones is consistent with several different histories.
That last word matters. Imagine inserting yew now. The array stays exactly as it was. Someone who receives a copy of the bits has no way to distinguish the history with yew from the history without it. The uncertainty survives even if they have unlimited time to inspect the array. The missing detail is which keys set the bits, and insertion deliberately threw it away.
Put the uncertainty where a mistake is cheap
Suppose a database keeps a filter for each of several immutable files. A query asks for one key. If a file’s filter says absent, the database can skip searching that file. If it says maybe, the database checks the file. A false positive costs extra work. The exact lookup still settles whether that file contains the key. RocksDB documents this use of Bloom filters for sorted table files.
Now use the same array to decide whether a new customer may create the username “yew”. If the application treats maybe as “already taken”, it can reject a perfectly good name. The filter behaved identically in both settings. The difference is who acts on a positive answer. In the database example a positive schedules an exact lookup. In the signup example it accidentally became the final decision.
There is a second condition hiding in the file example. The filter must describe the file being skipped. Pair yesterday’s filter with a file containing today’s new keys and a zero can send you away from real data. The mathematical guarantee is about keys inserted into this particular array. In a system, that translates into a concrete responsibility to associate each file with the filter built for its contents.
What does a one-percent error rate buy?
The denominator matters. A one-percent false-positive rate means that about one in a hundred queries for absent keys should say maybe under the assumed workload. It says nothing by itself about how often a positive answer is right. For that you also need to know how many of the requested keys actually exist.
Take a hypothetical batch of 10,000 lookups. Suppose 100 of the keys are present and 9,900 are absent. With a one-percent false-positive probability on those misses, expect about 99 false alarms. All 100 present keys also pass. Of about 199 positive answers, only about half correspond to a present key. Yet the filter still spares the database about 9,801 exact lookups. Those two facts describe the same successful filter.
Change only the mix. If 9,900 of the requested keys are present, only 100 requests can possibly be ruled out. At the same error rate, expect to skip about 99 exact lookups across the whole batch. Every request still pays for the filter check. Before tuning the number of bits, it helps to count how many misses the workload offers in the first place.
How many boxes should a key mark?
Adding a second hash gives an absent key another chance to hit a zero. Adding yet more hashes also means each insertion switches on more bits. The two effects pull in opposite directions. If almost every box is already on, checking another box rarely helps. If all eight boxes in the toy filter became one, every possible name would pass, regardless of which two box numbers it used.
A simple calculation explains the usual sizing estimate. With m boxes and independent, uniformly chosen positions, one mark misses a particular box with probability 1 − 1/m. After k marks for each of n distinct keys, the probability that the box is still zero is (1 − 1/m) raised to the power kn. Subtract that from one to estimate how full the array is likely to be.
As a rough illustration, if half the bits are on and a fresh absent key makes seven independent uniform probes into that fixed array, passing all seven has probability one half raised to the seventh power, about 0.78 percent. Real keys and hash functions need checking against those assumptions. Redis exposes capacity and target error rate as configuration choices. Its sizing guidance puts a one-percent target at roughly ten bits per item.
What breaks when you delete a name?
Go back to elm and ash. A tempting way to remove elm is to clear boxes one and four. Ask for ash again. Its second box, six, is still on. Its first box, four, is now off. The filter has just ruled out a name that is still present. The proof about bits staying on depended on never clearing a shared box.
One option for a fixed file is to build a fresh filter when a replacement file is produced. The replacement’s list of keys gives you the information the old bits lacked. Trying to recover that list from the old filter alone would run into the yew example again. Two different lists of names can produce exactly the same array.
There is a practical question you can ask before reaching for this structure. Finish the sentence “When the answer is maybe, my program will…” If the next step is to search a table, the cost of a false positive is easy to describe and measure. If the next step is to discard a message, deny a name or charge an account, write down whose data a collision would affect. The eight boxes never changed their promise. The program around them decides what that promise is worth.
Sources
Claims to verify
- Insert elm and ash. Check fern and yew against the resulting bits.
- Recalculate the expected false alarms with 100 present keys and 9,900 absent keys.
- Clear box four and test ash again.