---
title: "Enhancing Postgres to ClickHouse replication using PeerDB"
description: "PeerDB hardened its Postgres-to-ClickHouse CDC pipeline in four ways."
url: "https://swe.quest/articles/enhancing-postgres-to-clickhouse-replication-using-peerdb-3be51f7c6d9f7329"
canonical: "https://clickhouse.com/blog/enhancing-postgres-to-clickhouse-replication-using-peerdb"
source: "ClickHouse"
published: "2024-08-14"
difficulty: "medium"
kind: "Release"
reading_minutes: 4
tags: ["postgres","replication","event-driven","analytics","identity-auth"]
---

# Enhancing Postgres to ClickHouse replication using PeerDB

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-08-14, 4 min read, Release. Original: [https://clickhouse.com/blog/enhancing-postgres-to-clickhouse-replication-using-peerdb](https://clickhouse.com/blog/enhancing-postgres-to-clickhouse-replication-using-peerdb)

## Summary

PeerDB hardened its Postgres-to-ClickHouse CDC pipeline in four ways. It continuously drains the logical replication slot into an S3 stage, so WAL can't pile up when ClickHouse is down. It tunes ClickHouse memory settings (max\_block\_size, max\_insert\_block\_size, max\_threads, memory\_overcommit\_ratio\_denominator, dial\_timeout) to stop out-of-memory and overcommit-tracker failures on small clusters. It adds Lua row-level transformations for things like PII masking. On the security side, it uses short-lived IAM role credentials plus attribute-based access control on its multi-tenant S3 staging buckets.

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)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Event-driven architecture](https://swe.quest/tags/event-driven.md) (Backend & APIs)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)

## Prerequisites

- Postgres logical replication ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Change data capture
- ClickHouse basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

PeerDB, ClickHouse, PostgreSQL, ClickPipes, AWS S3, Lua, IAM, ABAC

## Related posts

- [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.
- [Postgres CDC in ClickHouse, A year in review](https://swe.quest/articles/postgres-cdc-in-clickhouse-a-year-in-review-6b9d350bcade98d4.md): ClickHouse · 2025-12-03 · Medium · 13 min read · PostgreSQL, Event-driven architecture, Data pipelines, Analytics & OLAP, Replication
  A year after PeerDB's acquisition, Postgres CDC into ClickHouse via ClickPipes has grown to 400+ companies replicating over 200 TB per month, driven by real-time customer-facing analytics and data warehousing workloads.
- [PostgreSQL + ClickHouse as the Open Source unified data stack](https://swe.quest/articles/postgresql-clickhouse-as-the-open-source-unified-data-stack-2760f19ba52907df.md): ClickHouse · 2026-01-27 · Easy · 5 min read · PostgreSQL, Analytics & OLAP, Event-driven architecture, Replication
  An open source stack pairs PostgreSQL as the transactional system of record with ClickHouse for analytics, connected by PeerDB for change data capture and the pg\_clickhouse extension, which transparently offloads analytical queries from Postgres to ClickHouse.
- [ClickHouse Partnership, improved Postgres Replication, and Disk Management](https://swe.quest/articles/clickhouse-partnership-improved-postgres-replication-and-disk-management-fc24b5541354f1b8.md): Supabase · 2024-10-30 · Medium · 4 min read · PostgreSQL, Analytics & OLAP, Replication, Event-driven architecture
  Supabase and ClickHouse are partnering around a Postgres-for-transactions, ClickHouse-for-analytics stack that is becoming common among AI companies.
- [Postgres Meets Analytics: CDC From Neon to ClickHouse Via PeerDB](https://swe.quest/articles/postgres-meets-analytics-cdc-from-neon-to-clickhouse-via-peerdb-669fe8e963909dd5.md): Neon · 2024-10-02 · Medium · 5 min read · PostgreSQL, Event-driven architecture, Analytics & OLAP, Replication, Data pipelines
  Neon serverless Postgres can serve as the transactional system of record while ClickHouse handles real-time analytics, with PeerDB streaming changes between them via Postgres logical replication.

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)
