WalShadow: Sub-second Postgres replication to ClickHouse from physical WAL
Recorded: Sept. 17, 2026, 12:28 a.m.
| Original | Summarized |
Introducing WalShadow: Sub-second Postgres replication to ClickHouse from physical WAL | ClickHouseSkip to contentCollapse the terminalCopy logo as SVGDownload full logoDownload logomarkOpen searchOpen region selectorEnglishJapaneseKoreanChineseFrenchSpanishPortugueseArabicOpen menuProductsProductsClickHouse CloudThe best way to use ClickHouse.Available on AWS, GCP, and Azure.Bring Your Own CloudA fully managed ClickHouse service,deployed in your own AWS, GCP or Azure account.ClickHouse Managed PostgresUnified data stack for transactionsand analytics.Managed ClickStackManaged observability with high-performancequeries and long-term retention.Langfuse CloudLLM observability and evaluations for reliable AI applications and agents.Open sourceClickHouseFast open-source OLAP database forreal-time analytics.ClickStackOpen-source observability stack for logs,metrics, traces, and session replays.Agentic Data StackBuild AI-powered applicationswith ClickHouse.chDBIn-process SQL Engine powered byClickHouse, with a Pandas-compatible APISolutionsUse casesReal-time analyticsObservabilityData warehousingMachine learning and GenAIAll use cases ->IndustriesFinancial servicesCybersecurityGaming and entertainmentE-commerce and retailAutomotiveEnergyAll industries ->DocsResourcesCompany resourcesUser storiesBlogEventsNewsLearning and certificationPartnersVideosDemosComparisonsBenchmark hubCostBenchBigQueryPostgreSQLRedshiftSnowflakeElastic ObservabilitySplunkDatadogOpenSearchFor observabilityDatabricksPricingContact usOpen searchToggle the web terminalOpen region selectorEnglishJapaneseKoreanChineseFrenchSpanishPortugueseArabic49.9kSign inGet Started->Scroll to top<-BackBlog/ProductCopy pageCopied!More actionsView as Markdown Open this page in MarkdownOpen in ChatGPT Ask questions about this pageOpen in Claude Ask questions about this pageOpen in v0 Ask questions about this pageIntroducing WalShadow: Sub-second Postgres replication to ClickHouse from physical WALSai SrirampurSep 10, 2026 · 7 minutes readToday, we’re announcing WalShadow, an open-source engine that replicates Postgres data to ClickHouse directly from physical WAL. Physical WAL is key to WalShadow’s architecture, but most managed Postgres services don’t expose it to customers, making it impossible to use WalShadow. ClickHouse Managed Postgres manages both sides of the stack, allowing us to integrate WalShadow directly into the Postgres replication layer and provide a native path from Postgres WAL to ClickHouse. WalShadow takes a new approach to Postgres-to-ClickHouse replication, effectively turning ClickHouse into an analytical physical standby. WalShadow consumes the same WAL stream Postgres generates for physical replication and recovery. Instead of asking the source database to decode changes into logical events, WalShadow processes the WAL outside the source through four stages: Track the live schema. WalShadow filters catalog WAL records and replays them into a schema-only shadow Postgres instance. This maintains an up-to-date catalog of tables, columns, and Postgres types as the source schema evolves. This creates a direct path from Postgres to ClickHouse: no logical decoding output plugin, no Kafka, and no JSON serialization or separate normalization step. The source only needs to ship physical WAL, resulting in a load profile similar to a physical standby while allowing changes to reach ClickHouse within a second. For a detailed overview of architecture, see the architecture documentation. To understand various available tuning settings affecting performance and functionality, see the configuration guide. Commit-to-visible latency measures the time from a transaction committing in Postgres to its rows becoming visible in ClickHouse. A native Postgres physical replica established a practical baseline of around 50 ms. WalShadow achieved approximately 200 ms, compared with around 10 seconds for PeerDB, about 50x lower latency in this benchmark. The source Postgres instance sustained approximately 290,000 inserted rows per second, establishing the maximum rate the replication pipeline could process. WalShadow replicated 289,000 rows per second, effectively matching the source without becoming the bottleneck. PeerDB sustained approximately 120,000 rows per second, or around 40% of the source rate. |
WalShadow is an open-source engine designed to replicate data from PostgreSQL to ClickHouse by directly consuming the physical Write-Ahead Log (WAL) stream, representing a novel approach to achieving sub-second data replication for analytical purposes. This methodology contrasts with traditional Change Data Capture (CDC) systems that rely on logical replication, as WalShadow processes the same physical WAL stream outside the source database, thereby eliminating the need for logical replication slots and significantly reducing the operational overhead associated with them. The system achieves performance benchmarks demonstrating low latency and high throughput, making data immediately available for analytics in ClickHouse. The core architecture of WalShadow involves processing the physical WAL stream through a parallelized, multi-stage pipeline. First, the system tracks the live schema by filtering catalog WAL records and replaying them into a shadow PostgreSQL instance, ensuring the catalog remains synchronized as the source schema evolves. Second, data changes are decoded in parallel across a pool of Rust-based decoders, avoiding bottlenecks associated with intermediate processing layers. Third, these decoded rows are grouped by table into complete ClickHouse-native blocks, maintaining data fidelity without requiring intermediate format conversions. Finally, a separate pool of inserters concurrently writes these blocks to ClickHouse, allowing the decoding and insertion processes to scale independently. This architecture establishes a direct link from Postgres to ClickHouse, bypassing logical decoding plugins, Kafka, and separate normalization steps. Correctness is maintained by attaching the source WAL position to every row, allowing ClickHouse to retain the latest version of data, although operations requiring strict ordering, such as schema changes, introduce barriers that enforce durability before application. For operational deployment, WalShadow supports the entire replication lifecycle, encompassing initial data loading, continuous replication, schema evolution, restart recovery, and planned source switchovers. Furthermore, the innovation is extended through integration with ClickHouse Managed Postgres, where WalShadow is implemented to access the physical WAL directly, a feature otherwise inaccessible in most managed services. This integration allows the system to operate natively within the Postgres replication layer, providing a direct path from WAL to ClickHouse blocks. Performance evaluations against existing CDC tools indicate significant advantages. Benchmarks demonstrated that WalShadow achieved a commit-to-visible latency of approximately 200 milliseconds, significantly lower than the around 50 milliseconds achievable by a native physical replica and about 10 seconds observed with PeerDB, resulting in approximately fifty times lower latency. Sustained throughput was also high, achieving a replication rate of 289,000 rows per second, effectively matching the source Postgres instance's maximum insertion rate while avoiding becoming a bottleneck, whereas conventional logical replication tools sometimes operate at only a fraction of the source rate. Ultimately, WalShadow represents a step toward a unified data stack by enabling seamless integration between PostgreSQL for transactional integrity and ClickHouse for high-speed analytical processing. By utilizing physical WAL replication, it delivers real-time analytics with minimal latency and reduced operational complexity, supporting advanced schema alterations that are often challenging for conventional logical decoding pipelines. The vision is to provide an efficient, low-overhead path for data movement that supports the demands of modern data architectures. |