Bloom filters: the niche trick behind a 16× faster API
incident.io cut P95 latency of its alert-filtering API for large organisations from 5s to 0.3s by pushing JSONB attribute filters into Postgres using bloom filters. Attribute key-value pairs are string-encoded, hashed with seven hash functions into a 512-bit bitmap stored as a bit(512) column, and queried with bitwise AND against bitmasks. With a 1% false-positive rate, only about 1% of the previous in-memory deserialization work remains. The bottleneck had been fetching and deserializing 500-row batches into Go structs. The team spiked a GIN index with jsonb_path_ops as the alternative and benchmarked both options before choosing.
Related posts
- Scaling Scientific Data: Migrating Benchling’s Schema Model for Performance at Scale
Benchling Engineering mediumAdept
Benchling replaced its PostgreSQL entity-attribute-value (EAV) storage for schema field values with a single JSONB column per entity, cutting row counts and per-row overhead that had slowed automated assay-result ingestion. Instead of a GIN index, which would slow inserts, entity linkages live in a separate table keyed by attribute name. The tradeoffs were more row-level lock contention, harder per-field queries and looser typing. The three-year migration ran in stages: dual writes with nightly integrity checks, then switching reads to JSONB, then removing the EAV tables. It produced up to 7x faster ingestion, roughly 2x faster analysis queries, and duplicate checks that dropped from minutes to 10-20 ms.
- The billion docs JSON Challenge: ClickHouse vs. MongoDB, Elasticsearch, and more
ClickHouse mediumAdept
JSONBench is a reproducible benchmark that loads up to one billion Bluesky event JSON documents into ClickHouse, MongoDB, Elasticsearch, DuckDB and PostgreSQL, then measures storage size and the speed of five analytical queries. ClickHouse's columnar JSON type stores each JSON path as a separate compressed column. In these tests it used 40% less storage and ran aggregations 2500x faster than MongoDB, used half the storage and ran 10x faster than Elasticsearch, and was several thousand times faster than DuckDB and PostgreSQL while using 5-6x less disk. The write-up explains each system's JSON storage model, compression, sorting, indexes and caches, and how each was configured for a fair comparison, such as MongoDB covered index scans and Elasticsearch with _source disabled.
- Space efficient machine learning feature stores using probabilistic data structures - a benchmark
Zalando Engineering mediumAdeptA Bloom-filter-backed in-process feature store matched a conventional key-value feature store's click-prediction accuracy (AUC ≈0.7997 vs ≈0.80) using about 3% of the memory (470MB vs 15GB). It kept 90% of the history uplift at roughly 40MB, with no measurable throughput cost. Features are stored as composite user^value keys and reconstructed by probing every possible value, so false positives inject tunable noise in exchange for space. The approach suits cases where an extra network call or many lookups per request are too expensive. It is not a drop-in replacement, though: you must know the full feature domain, high-volume real-time updates must hit every node, and deletions or expiry require rebuilding the filter from scratch.
- Timeseries indexing at scale
Datadog Engineering mediumAdeptDatadog replaced its timeseries index, which auto-generated materialized indexes from a log of slow queries, with an inverted index that unconditionally indexes every metric;tag pair, much like search engines map words to documents. The original Go service used SQLite for index definitions and the query log and RocksDB for Tagsets, Metrics and Indexes. It worked for predictable programmatic queries, but unpredictable user queries fell back to full scans, causing timeouts and manual index toil. The next-gen design drops SQLite, keeps RocksDB, and answers tag filters by intersecting posting lists of timeseries IDs. The two generations are compared on performance and reliability.
- SQL or NoSQL? Why not use both (with PostgreSQL)?
Supabase mediumAdeptPostgreSQL's JSONB columns let an app store nested, variable-length data (here, a daily food, water and exercise log) as a single row instead of spreading it across several normalized tables, while keeping SQL available for analysis. A worked example builds a calendar table with JSONB log fields and inserts a whole day in one statement. It then uses jsonb_array_elements with the -> and ->> operators to flatten the arrays into rows. Because aggregates cannot wrap set-returning functions, the flattened query goes into a CTE before summing daily calories or filtering for specific items.