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. 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. 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.
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 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, 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?
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 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. About every 15 seconds, the snowflake_cdc worker uses 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 across tables in the mirror with a default interval of 10 minutes.
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 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.
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 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 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.
During compaction, the PageServer converts changed pages from rows to Parquet and writes them to object storage. Lakebase and Lakehouse//RT read the same logical dataset. Lakehouse//RT on Lakebase is in Beta.
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 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.
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.
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 and Databricks stacks we tested.
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 registered in a shared catalog. ClickHouse also partially supports Delta Lake.
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.
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.












