---
title: "Data Hive: The story of beehiiv’s journey from Postgres to ClickHouse"
description: "beehiiv replaced its Postgres-and-Ruby-queue analytics system, which struggled with billions of email events and had multi-hour reporting delays, with a Kafka-fed ClickHouse Cloud pipeline."
url: "https://swe.quest/articles/data-hive-the-story-of-beehiiv-s-journey-from-postgres-to-clickhouse-467867cb2bebb87b"
canonical: "https://clickhouse.com/blog/data-hive-the-story-of-beehiivs-journey-from-postgres-to-clickhouse"
source: "ClickHouse"
published: "2024-08-21"
difficulty: "easy"
kind: "Case study"
reading_minutes: 6
tags: ["analytics","databases","postgres","stream-processing","messaging"]
---

# Data Hive: The story of beehiiv’s journey from Postgres to ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-08-21, 6 min read, Case study. Original: [https://clickhouse.com/blog/data-hive-the-story-of-beehiivs-journey-from-postgres-to-clickhouse](https://clickhouse.com/blog/data-hive-the-story-of-beehiivs-journey-from-postgres-to-clickhouse)

## Summary

beehiiv replaced its Postgres-and-Ruby-queue analytics system, which struggled with billions of email events and had multi-hour reporting delays, with a Kafka-fed ClickHouse Cloud pipeline. The design leans on ReplacingMergeTree for idempotent ingestion and event replay, dictionaries to enrich inserts without joins, ephemeral columns for intermediate calculations, materialized views as pre-aggregated shadow tables with alternate sort keys, and window functions for analytics. After six months the system held over 33 billion raw events in 1.5 TiB compressed (13 TiB uncompressed), with 22 ms median and 85 ms average query times. Creators now see send performance within seconds instead of hours.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Stream processing](https://swe.quest/tags/stream-processing.md) (Data & databases)
- [Queues & messaging](https://swe.quest/tags/messaging.md) (Backend & APIs)

## Prerequisites

- OLTP vs OLAP databases ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- Kafka basics ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))

## Keywords

ClickHouse, ClickHouse Cloud, Postgres, Kafka, ReplacingMergeTree, beehiiv, Ruby on Rails

## Related posts

- [“Just OLAP it”: How Ramp rebuilt its analytics platform on ClickHouse Cloud](https://swe.quest/articles/just-olap-it-how-ramp-rebuilt-its-analytics-platform-on-clickhouse-cloud-36298842faab88cc.md): ClickHouse · 2026-01-20 · Medium · 5 min read · Analytics & OLAP, Event-driven architecture, Data pipelines, PostgreSQL, Queues & messaging
  Ramp moved customer-facing spend analytics off its Postgres monolith after enterprise customers' reports on a single card-transactions table began taking 40+ seconds, and now serves them in milliseconds from ClickHouse Cloud.
- [98% faster queries, 50% lower cloud costs: Verihubs’ journey from Postgres to ClickHouse](https://swe.quest/articles/98-faster-queries-50-lower-cloud-costs-verihubs-journey-from-postgres-to-f6535061aff525b1.md): ClickHouse · 2026-07-06 · Medium · 6 min read · Analytics & OLAP, Data pipelines, PostgreSQL, Event-driven architecture
  Verihubs replaced a Postgres warehouse fed by daily Airflow batch pulls with a ClickHouse-based real-time OLAP stack.
- [How Kami scaled from 80M to nearly 2B events per week with ClickHouse](https://swe.quest/articles/how-kami-scaled-from-80m-to-nearly-2b-events-per-week-with-clickhouse-77ce1b06efbf532e.md): ClickHouse · 2025-05-16 · Medium · 7 min read · Analytics & OLAP, Data pipelines, PostgreSQL, Scaling, Schema migrations
  Kami's Postgres event tracking (Rails writing JSONB rows, queried via Redash) collapsed when COVID pushed weekly events from about 80M to nearly 2B.
- [Lago - Using ClickHouse to Scale an Events Engine](https://swe.quest/articles/lago-using-clickhouse-to-scale-an-events-engine-c476ec4bca3b5c9d.md): ClickHouse · 2024-05-29 · Medium · 7 min read · Analytics & OLAP, PostgreSQL, Payments & fintech, Performance engineering, Databases
  Lago, an open-source usage-based billing platform ingesting millions of events per minute, moved its streamed billable events from Postgres to ClickHouse Cloud and kept Postgres for all other transactional data.
- [Why Flock Safety turned to ClickHouse for real-time vehicle traffic analytics](https://swe.quest/articles/why-flock-safety-turned-to-clickhouse-for-real-time-vehicle-traffic-analytics-f35b2dcb28006f8a.md): ClickHouse · 2025-04-29 · Medium · 5 min read · Analytics & OLAP, Data pipelines, Cloud platforms
  Flock Safety replaced a once-daily Redshift, DBT, Prefect and QuickSight SPICE pipeline with ClickHouse Cloud.

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)
