TL;DR
When comparing thousands of massive datasets—like billion-user marketing audiences—in a cloud database, reading every byte to find exact overlaps is painfully slow and often unnecessary. Researchers at Adobe turned Bloom filters into "tunable" database-friendly sketches by splitting them into compressed blocks and deriving math to read only as many blocks as needed to hit a target error margin. The result? Turning a nearly two-hour SQL cross-overlap query into a three-minute sprint while still supporting individual membership checks.
What Problem Does This Paper Address?
Imagine you run a marketing platform with hundreds of customer segments ("audiences"), each holding millions to billions of anonymized IDs. You constantly ask three questions in SQL: Is user X in audience A? (membership), How many users are in A and B, but not C? (set expressions), and Which audiences in our catalog overlap with A by at least 50,000 users? (cross-overlap search).
Storing raw 64-bit hashes takes too much space and I/O. Standard cardinality sketches like HyperLogLog or Theta sketches shrink storage, but HyperLogLog gives up per-item membership testing, and Theta sketches grow linearly with set size for fixed thresholds. Classic Bloom filters (BFs)—bit arrays where items are marked using $k$ hash functions—preserve one-sided membership checks (no false negatives) and allow size estimation from bit occupancy. However, a single BF for a billion items exceeds 1 GiB. That won't fit in a relational database cell, can't be parallelized easily by a SQL engine, and forces you to read the whole gigabyte even when a rough overlap estimate would do.
Methods
The authors adapt Multi-Block Bloom Filters (MBFs)—originally designed for CPU caches—to database scale, pairing new statistical variance formulas with systems engineering:
- Database-Scale Blocked Layout: Instead of one giant bit-vector, an initial hash routes each item to one of $b$ independent BF blocks, stored one block per database row. Truncating a query simply means reading the first $b'$ blocks instead of all $b$.
- Set Algebra & Variance Math (New): Using the inclusion–exclusion principle, any expression using unions, intersections, and differences ($\cup, \cap, \setminus$) is mapped to partial unions of sketches. The authors derive novel first-order variance approximations for partial reads across blocks, turning desired standard deviation ($\sigma$) into a closed-form "accuracy dial" that calculates how many blocks ($b'$) to read.
- Three-Phase Adaptive Execution (New): Because you need bit densities to know how many blocks to read, queries run in three phases:
- Seed: Read 1 block per sketch; assume sets are disjoint to cheaply estimate a starting block budget $b'$.
- Main: Sweep forward through blocks $2 \dots b'$ using adaptive batching; re-evaluate variance without the disjoint assumption.
- Top-up: If a pair needs more precision, sweep backward from block $b$ downward so different pairs can share cached trailing blocks.
- Run-Length rANS Compression (Adapted): Sparse BF bit-vectors have long runs of zeros. The authors modify Range Asymmetric Numeral Systems (rANS) to encode entire runs of zeros in one step, reaching within a few percent of the theoretical Shannon entropy limit, while using Roaring Bitmaps for fast in-memory operations.
Datasets
The authors evaluate their SQL and Java UDF implementation on Snowflake using a synthetic benchmark catalog designed to mimic anonymized customer audiences and threshold-filtering queries:
- Two collections ($L$ and $R$) of 200 sets each (40,000 pairs total).
- Skewed sizes per collection: 120 sets of 10M items, 50 of 50M, and 10 each of 100M, 500M, and 3B items.
- Every pair across $L \times R$ is engineered to have an exact true overlap of 50,000 items, testing the system's ability to measure small, commercially relevant overlaps inside massive sets.
Key Insights and Ideas
- $k=1$ is King Under Compression: Textbook Bloom filters use $k \approx 7$ hash functions (for a 1% false-positive rate) to optimize uncompressed space at 50% bit density. Once you apply near-optimal entropy compression, $k=1$ (a single hash per item, yielding very sparse vectors) dramatically outperforms $k>1$ in both storage size and overlap accuracy per byte read.
- Disjointness Unlocks O(1) Pair Budgeting: Assuming two sets have zero overlap during Phase 1 collapses the variance math into a simple product of per-sketch bit odds ($o_1 \cdot o_2$). This lets the system compute initial read budgets for all $|L| \times |R|$ pairs by looking at individual sketches, before ever running a cross-join!
- Reverse Sweeps Save the Cache: When pairs need extra "top-up" blocks in Phase 3, continuing forward from each pair's unique stopping point $b'_{l,r}$ would scatter reads across different block IDs. Sweeping backward from block $b$ forces all pairs to pull extra blocks from a shared pool $\langle b, b-1, \dots \rangle$, maximizing cache hits.
Key Results
On a Snowflake 2X-Large warehouse running the $200 \times 200$ cross-overlap benchmark ($k=1, b=2,000$ blocks, rANS enabled):
- Massive Speedups: Full-read cross-overlap took 1h 54m. Accuracy-limited runs took 8m 22s at $\sigma = 5,000$ (~13.6$\times$ faster) and 3m 24s at $\sigma = 10,000$ (~33.5$\times$ faster). Across configurations with $k=1$, speedups ranged from 13–18$\times$ ($\sigma=5\text{K}$) to 34–42$\times$ ($\sigma=10\text{K}$).
- I/O Reduction: Theoretical analysis shows reading just 1.9% to 7.2% of block-pairs (a 14–53$\times$ reduction) suffices to estimate a 100K overlap at $\sigma=5,000$ for sets between 100M and 3B items.
- Tight Compression: rANS shrank total per-side catalog storage from 78.8 GiB (RoaringBitmap serialization) down to 42.7 GiB—a 1.85$\times$ reduction—with negligible runtime overhead.
- Reliable Precision: Sample standard deviations stayed within 15% of the requested $\sigma$ across size buckets (except where all 2,000 blocks saturated on 3B:3B pairs, or minimum 2-block rounding over-delivered accuracy on tiny sets).
Limitations and Future Work
- Pairwise Implementation Only: While the inclusion–exclusion math and variance formulas support arbitrary $\{\cup, \cap, \setminus\}$ formulas, the scalable 3-phase SQL implementation currently only handles pairwise cross-overlaps.
- Small Sets with Large Overlaps: Because Phase 1 assumes sets are disjoint, it under-budgets when overlaps are large relative to set sizes, pushing most of the reading work into Phase 3.
- Truncation Hurts Membership: While full MBFs support membership queries at 1% false-positive rates, reading truncated prefixes sharply increases false positives, limiting partial reads to cardinality estimation.
- Future Directions: Extending the SQL engine to general set expressions, conducting head-to-head empirical benchmarks against HyperLogLog/SetSketch/Theta sketches, and exploring hybrid queries (e.g., intersecting an MBF with a raw hashed sample).
Summary updated