# Follow the WAL: Postgres to analytics on ClickHouse, Snowflake and Databricks

> Source: <https://clickhouse.com/blog/follow-the-wal-postgres-to-analytics>
> Published: 2026-12-03 17:12:44.389310+00:00

**Recommendation:** When an agent reads analytics right after writing to Postgres, account for replication lag: ClickHouse measured 308 ms median ingest and 592 ms to query visibility, so re-check or wait before trusting the result.
More in the playbook "Running AI in production": <https://wpnews.pro/playbooks/production-ops>

## TL;DR

We followed a Postgres commit through ClickHouse, Snowflake, and Databricks to see how quickly each engine can query fresh writes.

In our [open benchmark](https://github.com/ClickHouse/pg-sync-bench), a ClickHouse query saw the full transaction a median of **592 ms** after commit acknowledgment with WalShadow. Snowflake documents about **30 seconds** to visibility with default settings. Databricks uses shared durable storage and merges recent changes at query time.

An AI agent updates several orders in Postgres, then asks how this week’s on-time delivery rate compares with last week’s. How likely is it that it gets an answer that includes the orders it just updated?

The first operation updates specific records, while the second aggregates delivery history by week. Postgres handles the updates, but a purpose-built analytical database is better suited to run the second query at scale. The challenge is getting the latest writes to the analytical engine in time for the next query.

Bringing transactions and analytics together [is a decades-old challenge](https://ieeexplore.ieee.org/document/1423297). AI agents make it more pressing because they can query the data as soon as a write commits and use the answer to decide what to do next.

We modeled this workflow in [an open benchmark](https://github.com/ClickHouse/pg-sync-bench). While Postgres averaged **about 10,000 commits per second**, the estimated median ingest lag into ClickHouse Cloud was **308 ms**.

Snowflake and Databricks are also investing in solving this problem. In this article, we’ll follow a Postgres commit through all three systems, from the write-ahead log to the analytical query and compare the architectures.

## Follow the WAL

To understand how these platforms make operational data ready for fast analytical queries, we need to know how the writes are processed by Postgres and shared with the analytical engine.

It all starts with a transaction in Postgres. When an application inserts, updates, or deletes rows, Postgres records the changes and the commit in its write-ahead log (WAL). Postgres uses the WAL to recover in case of a crash.

The WAL is the common starting point for all three platforms. Turning physical WAL records into rows requires knowing the table’s schema at the time of the write and reassembling changes by transaction. The designs diverge in where they process the WAL, how they lay out the data, and what the analytical engine reads when the agent asks its next question.

## ClickHouse: Two engines with low-latency replication

ClickHouse Managed Postgres keeps the rows, indexes, and WAL on local NVMe, while ClickHouse Cloud stores its analytical copy in its native columnar format. Each database stores the data in the layout its own workload reads fastest. To keep the data in Postgres replicated to ClickHouse Cloud, we built [WalShadow](https://clickhouse.com/blog/introducing-walshadow), currently in private preview.

WalShadow streams the physical WAL using the same protocol as a Postgres standby. It filters and replays catalog records in a shadow Postgres instance to track the source schema. Rust decoders use that schema to turn heap records into typed rows, and WalShadow batches committed changes into native ClickHouse INSERT blocks. Replication runs asynchronously, so Postgres can acknowledge a commit before the changes reach ClickHouse. The sub-second timing in the diagram reflects benchmark results and varies by workload.

Applications can use the same Postgres connection for transactions and analytics. The writes run in Postgres, and `pg_clickhouse` pushes supported analytical queries down to ClickHouse.

The main challenge with this approach is replication latency. In our example of an agent managing deliveries, if the agent queries ClickHouse immediately after committing to Postgres, it may still see the earlier state. How long does it take for all the delivery changes to become visible?

### How quickly changes make it to ClickHouse Cloud

We benchmarked the order delivery workflow described in the introduction to see how quickly data replicates from Postgres to ClickHouse. Postgres averaged about 10,000 commits per second, with a median writer commit latency of 4.2 ms. The chart below shows estimated per-row ingest lag of **308 ms at the median and 561 ms at p99, before any client query.**

Each transaction marked one order as delivered, updated its three line items, and removed its entry from the pending orders table. To measure how long it took a client to see the complete delivery, we polled ClickHouse every 100 ms until a single response reflected all five changes. The time from Postgres commit acknowledgment to that response was **592 ms at the median and 892 ms at p99**.

The last of the five changes to become visible determines when the client can see the complete delivery. The timing also includes up to 100 ms of waiting for the next poll and the time it takes ClickHouse to run the query and return the response.

## Snowflake stages changes in Iceberg

Snowflake also keeps a separate copy for analytics. When an application writes to Snowflake Postgres, a `walsender` uses a logical replication slot to [decode the write-ahead log (WAL) into row-level inserts, updates, and deletes](https://www.snowflake.com/en/blog/engineering/postgres-to-snowflake-replication-mirroring/). About every 15 seconds, the `snowflake_cdc` worker uses [`pg_lake`](https://github.com/Snowflake-Labs/pg_lake) to write a batch to per-table `$changes` logs in Iceberg. It also records which batches are ready in a metadata log called the *metalog*. The same Postgres instance that serves the application does the decoding and batching.

On the Snowflake side, a scheduled task reads the metalog and applies pending batches to the target tables. [Changes from the same Postgres transaction become visible together](https://docs.snowflake.com/en/user-guide/snowflake-postgres/postgres-data-mirroring#transactional-guarantees) across tables in the mirror with a default [interval of 10 minutes](https://docs.snowflake.com/en/user-guide/snowflake-postgres/postgres-data-mirroring-create#step-3-create-the-mirror).

Snowflake’s `$live` view combines the target table with pending changes from its Iceberg change log when a query runs. With default settings, Snowflake documents [about 30 seconds](https://docs.snowflake.com/en/user-guide/snowflake-postgres/postgres-data-mirroring-performance#how-mirroring-works) from write to visibility through `$live`, independent of when the apply task merges those changes into the target table.

For context, in our ClickHouse delivery benchmark, the median time from Postgres commit acknowledgment to a response showing all five changes was **592 ms**. Snowflake notes that [`$live` can briefly show only some of the changes from a transaction](https://docs.snowflake.com/en/user-guide/snowflake-postgres/postgres-data-mirroring-query#query-at-low-latency-with-live).

A `$live` query reads the changes still waiting to be applied. As that backlog grows, the query has more rows to scan, which can increase its cost.

A lag of about 30 seconds means, in practice, that an agent querying the analytical layer right after a batch of operations on Postgres will query stale data.

## Databricks builds around one durable copy

Databricks takes a different approach and relies on a single durable copy of the data shared by both the operational and analytical engines. When an application writes to Postgres in Lakebase, the commit becomes durable once a quorum of [SafeKeeper nodes](https://www.databricks.com/blog/lakebase-ltap-rethinking-database-storage#scaling-writes-wal-becomes-safekeeper) has recorded it in the WAL. The PageServer replays that log to bring the Postgres pages up to date. Postgres serves reads from its local caches when it can and [fetches pages from the PageServer on a cache miss](https://www.databricks.com/blog/built-object-storage-served-cache).

During compaction, the PageServer [converts changed pages from rows to Parquet](https://www.databricks.com/blog/lakebase-ltap-rethinking-database-storage#materializing-in-columnar-form) and writes them to object storage. Lakebase and Lakehouse//RT read the same logical dataset. Lakehouse//RT on Lakebase is in [Beta](https://docs.databricks.com/aws/en/oltp/projects/query-lakehouse-rt).

What happens if an agent runs an analytical query before the write reaches Parquet?

Lakehouse//RT asks Postgres for its current log sequence number (LSN), which marks the point in the WAL the query should read as of. It scans the Parquet data already in object storage and [fetches and merges newer page versions from the PageServer](https://docs.databricks.com/aws/en/oltp/projects/ltap-overview#purpose-built-engines) up to that cutoff.

The fetch and merge add work at query time. How much they affect query latency depends on how many of the pages the query needs have changed since compaction. Databricks describes the read path and Parquet materialization, with no published latency benchmark comparable to the test we described above.

## Closing thoughts on the approaches

### How the three platforms compare

In this article we saw how a Postgres write takes a different path to analytics on each platform. The table below summarizes where that work happens, when the data becomes visible, and what the query still has to do.

|  | ClickHouse | Snowflake Data Mirroring | Databricks Lakebase | 
|---|---|---|---|
| **WAL processing** | Physical WAL decoded off the Postgres primary using WalShadow | Logical WAL decoded on source Postgres | Lakebase PageServer replays the physical WAL | 
| **What queries read** | Native ClickHouse tables | Iceberg tables plus pending changes in `$live` | Parquet plus recent PageServer updates | 
| **Freshness** | Sub-second measured freshness | About 30 seconds | No comparable response timing documented | 
| **Query-time extra work** | None | Combines the target with pending Iceberg changes | Merges recent PageServer pages with Parquet | 
| **Availability** | [WalShadow is in private preview](https://clickhouse.com/docs/products/managed-postgres/sync-to-clickhouse/walshadow) | [Generally available](https://docs.snowflake.com/en/release-notes/2026/other/2026-10-15-postgres-data-mirroring-ga) | [Beta](https://docs.databricks.com/aws/en/oltp/projects/query-lakehouse-rt) | 

Snowflake and Databricks both do some work at query time to include recent Postgres writes. Their documentation describes how each system does it, but it's left unclear how much extra work it actually does. We haven't benchmarked the systems to precisely measure this.

However, we did compare ClickHouse Cloud against Snowflake and Databricks on the real-time analytics use case with CostBench which asked a related question on a different workload: How efficiently can each platform serve fresh answers while data is still arriving? We continuously ingested stock quotes and ran analytical queries throughout, measuring data preparation cost, query cost, and query runtime, and ClickHouse Cloud delivered better end-to-end performance per dollar than the [Snowflake](https://clickhouse.com/blog/clickhouse-vs-snowflake-real-time-performance-per-dollar) and [Databricks](https://clickhouse.com/blog/clickhouse-vs-databricks-real-time-performance-per-dollar) stacks we tested.

### Sharing Postgres data across engines

Open table formats let teams query operational data from different engines. Snowflake stages changes in Iceberg and offers Iceberg mirror tables. Databricks materializes Lakebase data in a form that other engines can read through Delta Lake or Iceberg.

WalShadow replicates Postgres changes into native ClickHouse tables for low-latency queries. To close the gap with Databricks and Snowflake on data interoperability, it’s good to know that teams can use a scheduled materialized view to publish changes from native ClickHouse tables to an [Apache Iceberg table](https://clickhouse.com/docs/guides/use-cases/data-warehousing/getting-started/writing-data) registered in a shared catalog. ClickHouse also [partially supports Delta Lake](https://clickhouse.com/docs/reference/engines/table-engines/integrations/deltalake#insert-data).

The delivery agent can query the updates as soon as they reach ClickHouse and use the answer to make its next decision. Other teams can query the published lake copy through their own tools as it refreshes.

## Conclusion

Making operational data available to the analytical engine at agent speed is critical for AI-driven workflows. At ClickHouse, we built an open benchmark to help you measure that latency at scale. We hope you’ll give it a try in your own deployment and see how your results measure up against your SLA.
