---
title: "How SewerAI is using ClickHouse to modernize sewer management at scale"
description: "SewerAI replicates its Postgres transactional data into ClickHouse via CDC (moving from Confluent/Debezium to self-hosted Debezium+Kinesis to PeerDB, and now ClickPipes) and uses materialized and refreshable materialized views to denormalize 40+ tables into a single hundreds-of-billions-row \"Megatable\" for real-time municipal analytics."
url: "https://swe.quest/articles/how-sewerai-is-using-clickhouse-to-modernize-sewer-management-at-scale-b730a0ec357c6359"
canonical: "https://clickhouse.com/blog/sewerai-sewer-management-at-scale"
source: "ClickHouse"
published: "2025-09-19"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["analytics","data-pipelines","performance","cost-optimization","postgres"]
---

# How SewerAI is using ClickHouse to modernize sewer management at scale

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-09-19, 7 min read, Case study. Original: [https://clickhouse.com/blog/sewerai-sewer-management-at-scale](https://clickhouse.com/blog/sewerai-sewer-management-at-scale)

## Summary

SewerAI replicates its Postgres transactional data into ClickHouse via CDC (moving from Confluent/Debezium to self-hosted Debezium+Kinesis to PeerDB, and now ClickPipes) and uses materialized and refreshable materialized views to denormalize 40+ tables into a single hundreds-of-billions-row "Megatable" for real-time municipal analytics. Bulk customer operations caused update failures and backlogs because compute was always near its limit. The fixes were incremental refreshes over only the last ~70 seconds of data, projections on clean tables, dictionaries instead of LEFT ANY joins, join ordering, LIMIT instead of DISTINCT, and filtering before joins, which alone gave about 3x speed at half the compute. With these changes, data volume tripled and read/write operations rose tenfold while compute usage stayed flat.

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)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)

## Prerequisites

- ClickHouse basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- materialized views
- change data capture
- SQL joins ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

ClickHouse, PeerDB, ClickPipes, Debezium, PostgreSQL, refreshable materialized views, SewerAI

## 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.
- [How Seemplicity scaled real-time security analytics with Postgres CDC and ClickHouse](https://swe.quest/articles/how-seemplicity-scaled-real-time-security-analytics-with-postgres-cdc-and-c80fc0ac79e77c01.md): ClickHouse · 2025-05-29 · Easy · 6 min read · Event-driven architecture, Analytics & OLAP, PostgreSQL, Multi-tenancy, Data pipelines
  Seemplicity, a security remediation platform aggregating findings from 150+ tools, outgrew a Postgres-only design as heavy upserts, table bloat and multi-table joins across ~16 per-tenant tables slowed customer dashboards.
- [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.
- [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.

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)
