---
title: "Bloom filters: the niche trick behind a 16× faster API"
description: "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."
url: "https://swe.quest/articles/bloom-filters-the-niche-trick-behind-a-16-faster-api-f8c936f8ee9c7bb2"
canonical: "https://incident.io/blog/bloom-filters"
source: "incident.io"
published: "2025-11-14"
difficulty: "medium"
kind: "Case study"
reading_minutes: 16
tags: ["postgres","data-structures","performance","api-design"]
---

# Bloom filters: the niche trick behind a 16× faster API

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2025-11-14, 16 min read, Case study. Original: [https://incident.io/blog/bloom-filters](https://incident.io/blog/bloom-filters)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Data structures](https://swe.quest/tags/data-structures.md) (Architecture & design)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)

## Prerequisites

- SQL and Postgres indexes ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- JSONB
- hash functions

## Keywords

bloom filter, PostgreSQL, GIN index, JSONB, ULID, incident.io

## Related posts

- [Scaling Scientific Data: Migrating Benchling’s Schema Model for Performance at Scale](https://swe.quest/articles/scaling-scientific-data-migrating-benchling-s-schema-model-for-performance-at-eb9ad927a91c702e.md): Benchling Engineering · 2024-12-04 · Medium · 10 min read · PostgreSQL, Schema migrations, Performance engineering, Scaling
  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.
- [The billion docs JSON Challenge: ClickHouse vs. MongoDB, Elasticsearch, and more](https://swe.quest/articles/the-billion-docs-json-challenge-clickhouse-vs-mongodb-elasticsearch-and-more-e942a192bad31355.md): ClickHouse · 2025-01-29 · Medium · 28 min read · Analytics & OLAP, Databases, Storage engines, Performance engineering
  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.
- [Space efficient machine learning feature stores using probabilistic data structures - a benchmark](https://swe.quest/articles/space-efficient-machine-learning-feature-stores-using-probabilistic-data-be147985e009951b.md): Zalando Engineering · 2021-10-04 · Medium · 9 min read · ML platforms, Data structures, Recommendations & ranking, Machine learning
  A 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).
- [Timeseries indexing at scale](https://swe.quest/articles/timeseries-indexing-at-scale-cbd6b9bd5fe12d35.md): Datadog Engineering · 2024-06-28 · Medium · 20 min read · Storage engines, Search, Databases, Observability, Scaling
  Datadog 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.
- [SQL or NoSQL? Why not use both (with PostgreSQL)?](https://swe.quest/articles/sql-or-nosql-why-not-use-both-with-postgresql-98c239e2ff7e761c.md): Supabase · 2022-11-24 · Medium · 12 min read · PostgreSQL, SQL, Databases
  PostgreSQL'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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
