---
title: "Building a product analytics solution with ClickHouse"
description: "ClickHouse's in-house product analytics platform, Galaxy, stores over 20 billion events (14 TB, roughly 14x compression) in a single denormalized MergeTree table keyed on created_at."
url: "https://swe.quest/articles/building-a-product-analytics-solution-with-clickhouse-786424348993d92f"
canonical: "https://clickhouse.com/blog/building-product-analytics-with-clickhouse"
source: "ClickHouse"
published: "2024-12-05"
difficulty: "medium"
kind: "Case study"
reading_minutes: 24
tags: ["analytics","sql","databases","product-engineering"]
---

# Building a product analytics solution with ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-12-05, 24 min read, Case study. Original: [https://clickhouse.com/blog/building-product-analytics-with-clickhouse](https://clickhouse.com/blog/building-product-analytics-with-clickhouse)

## Summary

ClickHouse's in-house product analytics platform, Galaxy, stores over 20 billion events (14 TB, roughly 14x compression) in a single denormalized MergeTree table keyed on created\_at. A single sparse table avoids join overhead, since ClickHouse's sparse serialization makes empty columns cheap. Columns used for cohorts and filters should be top-level rather than buried in a JSON payload. Incremental materialized views speed up the few dozen recurring queries, and a custom SDK handles event capture.

Written by swe.quest, not by the author.

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

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Product engineering](https://swe.quest/tags/product-engineering.md) (Engineering organization)

## Prerequisites

- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- columnar databases basics ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

ClickHouse, Galaxy, MergeTree, materialized views, PostHog, ClickHouse Cloud

## Related posts

- [What Replo learned optimizing 100+ billion events in ClickHouse](https://swe.quest/articles/what-replo-learned-optimizing-100-billion-events-in-clickhouse-4b7228146ec28a74.md): ClickHouse · 2026-03-09 · Medium · 7 min read · Analytics & OLAP, Databases, Performance engineering, Scaling
  Replo's in-product analytics for Shopify merchants ingests 3,000-5,000 events per second into ClickHouse and analyzes 100+ billion events, but reaching that point took several data-model resets.
- [Accelerating ClickHouse queries on JSON data for faster Bluesky insights](https://swe.quest/articles/accelerating-clickhouse-queries-on-json-data-for-faster-bluesky-insights-cce6ed7a467f6449.md): ClickHouse · 2025-03-19 · Medium · 29 min read · Analytics & OLAP, Performance engineering, SQL, Databases
  Incremental materialized views feeding AggregatingMergeTree tables cut ClickHouse dashboard queries over 4+ billion Bluesky JSON documents (1.6 TiB) from 44–56 seconds to 3–7 ms. Partial aggregation states are computed only for newly inserted rows and merged in the background, so the pre-aggregated tables stay tiny (e.g. 892 rows, 11 KiB) and constant-size regardless of source growth.
- [Using Materialized Views in ClickHouse](https://swe.quest/articles/using-materialized-views-in-clickhouse-f547ca7b5675b5e9.md): ClickHouse · 2023-01-19 · Medium · 13 min read · Analytics & OLAP, SQL, Performance engineering, Data pipelines
  ClickHouse materialized views act as insert-time triggers that write the result of a SELECT into a target table, letting expensive aggregations be precomputed.
- [Data Hive: The story of beehiiv’s journey from Postgres to ClickHouse](https://swe.quest/articles/data-hive-the-story-of-beehiiv-s-journey-from-postgres-to-clickhouse-467867cb2bebb87b.md): ClickHouse · 2024-08-21 · Easy · 6 min read · Analytics & OLAP, Databases, PostgreSQL, Stream processing, Queues & messaging
  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.
- [Harnessing the Power of Materialized Views and ClickHouse for High-Performance Analytics at Inigo](https://swe.quest/articles/harnessing-the-power-of-materialized-views-and-clickhouse-for-high-performance-ebcfa2d951da7c43.md): ClickHouse · 2023-06-23 · Medium · 8 min read · Analytics & OLAP, Databases, SQL, Performance engineering
  Inigo stores analytics on billions of GraphQL API requests in ClickHouse after rejecting Snowflake as too slow and costly for customer-facing data and lacking a local emulator, and PostgreSQL because its indexes and costs blew up past roughly 100K–1M rows.

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)
