Xor filter explained in plain terms means understanding the membership test that stores fingerprints so cleverly it beats the Bloom filter on both size and speed, a data structure from a 2020 paper that finally made an old idea practical. The central question is why anyone would replace the Bloom filter when it has worked for fifty years, and the answer is that the Bloom filter wastes memory and time on random accesses, so a filter that needs only three lookups and a quarter less space is simply better.
An xor filter is a compact data structure for approximate set membership, introduced by Thomas Mueller Graf and Daniel Lemire in their paper Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters. It stores a fingerprint for each key across three arrays so that the xor of three entries equals the fingerprint, which means a lookup reads three spots and xors them, and because the construction is a puzzle solved once at build time, queries stay fast forever.
This article makes the case for xor filters, what they are, how they work, and where they run in the real world.
Key takeaways
- Xor filters test membership with three lookups.
- Graf and Lemire introduced them in 2020.
- They use about 23 percent more than the lower bound.
- Bloom filters use 44 percent more than the bound.
- They are static, so they cannot add or delete keys.
What an xor filter is
An xor filter is a membership structure that turns each key into a fingerprint and stores it as the xor of three array entries, and that trick is what makes it unusual among filters. Each key hashes to three positions, one in each of three arrays, which means the fingerprint is never stored in one place, and because the three entries xor to the fingerprint, a lookup that finds a different xor knows the key is absent.
Its signature feature is the near-optimal size. Most filters waste space on overhead, but an xor filter needs only about 1.23 times the theoretical minimum, which means it beats a Bloom filter’s 1.44 times by a clear margin, and because the saving comes from the fingerprint trick rather than compression, queries stay fast.
The design was a reaction to the Bloom filter’s waste. Dietzfelbinger and Pagh had described the xor idea in 2008 but never implemented it, so Graf and Lemire asked whether it could be built and benchmarked properly, because a good idea without measurements is a good idea nobody trusts, and that practicality is what made the xor filter worth building.
It became one of the best-known membership filters in the world, and it is named in every discussion of the field. The paper appeared in the Journal of Experimental Algorithmics in 2020, the compact xor plus variant pushes the overhead down to 15 percent, binary fuse filters later improved on the same idea, and it is still the first example engineers meet when they learn that a Bloom filter can be beaten, which means the design survives as a reference even though newer filters exist.
Our guide to cuckoo filters explains the deletable filter xor filters are measured against, and our guide to quotient filters explains the resizable filter that trades speed for flexibility.
How an xor filter works
Everything starts with the fingerprint, which sets the key’s compact form. An xor filter hashes each key into a short fingerprint, which means the filter depends on fingerprints alone, and because the fingerprint is only a few bits, the whole structure stays small.
Each step begins with the three hashes, which pick the positions. The filter hashes the key three times to choose one slot in each of three arrays, which means every key has exactly three homes, and because the positions are random-looking, the entries spread evenly across the arrays.
Construction is what makes the design work as a whole. The builder solves for array entries so that the xor of each key’s three entries equals its fingerprint, which means building is a peeling puzzle that fills the arrays in the right order, and because the puzzle is solved once, the filter never needs to change afterwards.
Lookup spreads the effect further. The filter reads the three entries for a key and xors them, which means a match means the key is probably present, and because the check touches only three cache-friendly spots, the answer comes back faster than a Bloom filter’s many random reads.
The false positive rate is what turns the design into a fair trade. An xor filter can say probably present when the key is absent, which means it must never be the final word on membership, and because the rate is set by the fingerprint length, a longer fingerprint buys certainty at the cost of space.
The result comes from the xor check, read out as probably present or definitely absent. An xor filter returns a definite no when the xor does not match, which means the result is certain in one direction whatever the input, and that certainty is exactly what a membership test needs.

Comparing xor filters with other filters
An xor filter is one of several membership structures built to answer probably-in-the-set, and each was built with a different emphasis. A Bloom filter is the classic bit array built for minimal code, a cuckoo filter is the fingerprint filter built to delete cheaply, and an xor filter is the one built to be small and fast, while each approach trades something for something else.
The table below sets out the main contrasts between the leading approaches.
| Aspect | Xor filter | Bloom filter | Cuckoo filter |
|---|---|---|---|
| Space overhead | About 23 percent | About 44 percent | About 30 percent |
| Lookups per query | Three | Many | Two |
| Deletion | No | No | Yes |
| Resizing | Rebuild needed | Rebuild needed | Rebuild needed |
| Best for | Static sets, speed | Simple code | Fast deletion |
The practical result is that an xor filter is the right choice for static sets and speed, a Bloom filter suits simple code, and a cuckoo filter fits fast deletion instead.
Where xor filters are used
Databases use them to skip disk reads. A store checks the filter before touching slow storage, because a definite no saves a whole read, and that saving is the reason the filter earns its keep in database code.
Search engines use them inside indexes. A search system checks the filter before scanning a posting list, because a fast no keeps queries cheap, and that speed is the reason the design was built for real traffic.
Networks use them to track known sets. A router checks the filter before forwarding a lookup, because a fast answer keeps packets moving, and that speed is the reason the xor filter appears in networks far beyond its database origins.
Benchmarking uses them as the compact reference. Engineers still quote xor filters when they discuss how small a membership test can be, because they are the clearest example of beating Bloom on its own ground, and that number shapes how new filters are measured.
Teaching uses them as the construction example. Courses introduce xor filters when they explain that building a data structure can be a puzzle, because they are the clearest case of a clever build buying fast queries, and a student who understands xor filters understands why construction cost and query cost are a trade-off.
Strengths and limits
The greatest strength of an xor filter is its size and speed together. A filter that is both smaller and faster than Bloom is a rare combination, and that strength is real, measured in the paper’s own benchmarks and confirmed by the systems that adopted it.
It is also a strength that queries are simple. A lookup is three reads and two xors, and that simplicity is worth more than cleverness in a field where a filter that needs complex logic is a filter that wastes time.
The limits are real, though, and the biggest is that the filter is static. An xor filter cannot add or delete keys after construction, which means a changing set needs a rebuild, and a system that needs updates must choose a cuckoo or quotient filter instead.
Xor filter checklist
- Use xor filters for static sets, never for changing ones.
- Remember Graf and Lemire introduced them in 2020.
- Note three lookups answer every query.
- Compare them with Bloom to see two generations of one idea.
- Study the construction puzzle, which is what makes queries fast.
- Check the false positive rate, since short fingerprints err more.
- Keep real membership checks behind the actual data store.
- Read the 2020 paper to see how the filter was built.
- Choose an xor filter when space and speed both matter.
Frequently asked questions
What is an xor filter in simple terms?
It is a compact structure that stores fingerprints split across three arrays, so a lookup xors three entries to test membership.
Who created the xor filter?
Thomas Mueller Graf and Daniel Lemire, in a paper published in the Journal of Experimental Algorithmics in 2020.
How is an xor filter different from a Bloom filter?
Both test membership, but an xor filter uses less space and fewer lookups, while a Bloom filter is simpler to build.
Is an xor filter still secure?
It is fast and well tested, but it can give false positives, so it must never be the final word on whether an item is present.
Where are xor filters used?
In databases, in search indexes, in networks, and in teaching about compact data structures.
When should I use an xor filter?
When you need fast membership tests on a fixed set, when space matters, or when you study modern filter design.
The bottom line
Xor filter explained in one line is this: a Bloom filter beaten at its own game, a 2020 design that split fingerprints across three arrays and taught the field that a fifty-year-old idea can still be improved.
It is proof that a clever construction beats a bigger table, and the reason it still matters is that every filter designed since has been judged partly by the lesson the xor filter taught.
This article is general information about how an xor filter works, not advice about choosing encryption for a particular device or system.







