Skip to content

GuidesRealtime

Can Iceberg do realtime SQL? How fresh and how fast, from Postgres insert to next query

How fresh and how fast can Apache Iceberg be? What limits freshness (commit intervals) and query speed (small files, deletes, metadata caching), and how to get a Postgres insert into the next SQL query in about a second.

Yes, if the writer commits often and the reader can keep up. The Iceberg format doesn't impose a freshness limit: a row is visible to every reader as soon as the commit that contains it lands in the catalog. Freshness depends on how often your ingestion tool commits. That ranges from minutes for a default Kafka Connect sink to under a second for tools built for it. Query speed on fresh data depends on how the table handles the small files and delete files that frequent commits create, and on whether the engine re-reads table metadata on every query. For realtime SQL on Iceberg you need three things: ingestion that commits within about a second, compaction and deletion vectors to keep files healthy, and an engine that reads the latest snapshot on every query with little overhead per query.

What does "realtime" mean for an Iceberg table?

Two separate numbers get called "realtime," and you need to measure both:

  • Freshness: the time from a COMMIT in your source database to the row showing up in a query result.
  • Query latency: how long the query itself takes, especially a small one such as a lookup by key or a dashboard tile.

A table can be fresh and slow (commits every second, thousands of tiny files) or fast and stale (compacted nightly). Realtime means both numbers are small at the same time.

How does a Postgres row get into an Iceberg query?

Every path from Postgres to an Iceberg query goes through the same steps:

  1. The transaction commits in Postgres and is written to the WAL.
  2. A CDC process reads it through logical replication.
  3. The process buffers changes and writes Parquet data files, plus delete files or deletion vectors for updates and deletes.
  4. It commits a new snapshot to the Iceberg catalog. Only now can readers see the change.
  5. A query engine loads the table's current metadata, plans which files to read, and scans them from object storage or a local cache.

Steps 3 and 4 set freshness. Steps 3 and 5 set query latency.

What limits freshness?

Mostly the commit interval you choose, or the default you inherit:

Ingestion pathWhen data becomes visibleSource
Kafka + Apache Iceberg Kafka Connect sinkAt each commit, every 5 minutes by default (iceberg.control.commit.interval-ms = 300,000)Iceberg Kafka Connect docs
Flink (Iceberg sink or Flink CDC)When a Flink checkpoint completesIceberg Flink writes
Debezium Server + Iceberg sinkPer batch. The default doesn't wait, and batch-size wait strategies trade freshness for fewer filesDebezium Server
pg2icebergWhen the materializer runs, on an interval you setpg2iceberg
pg_mooncake / MoonlinkAbout half a second from another session, read through the extensionpg_mooncake
Contrast FlowAs each transaction commits to Iceberg. p95 was 0.48 to 0.93 s in 4 of 7 load testsFlow

You can shorten most of these intervals. The cost is more commits, which means more small files and more metadata to plan through. Iceberg uses optimistic concurrency, so several writers committing often to the same table also retry against each other.

What limits query speed on fresh data?

Small files

Each commit adds at least one data file per table it touches. Planning and opening thousands of small files costs more than reading a few large ones, and on object storage each file is another round trip. Iceberg's docs recommend compacting small files with rewriteDataFiles (maintenance). For a realtime table, compaction has to run continuously, not nightly.

Updates and deletes

A CDC stream is full of updates. Iceberg v2 represents them with position delete files or equality delete files. Equality deletes are cheap for the writer, because it only records the key, but every reader has to apply them against the data files until compaction rewrites them. Iceberg v3 adds deletion vectors, a compact bitmap of deleted row positions per data file, and the v4 spec stops new equality deletes (Iceberg spec). For update-heavy realtime tables, prefer a writer that produces deletion vectors or compacts equality deletes quickly.

Metadata caching

Engines cache table metadata to avoid a catalog round trip on every query. That speeds up repeated queries, but it means a query can miss commits made after the cache was filled. For example, the ClickHouse and DuckDB configurations in Contrast's benchmarks reuse metadata for 60 seconds (benchmark setup). If you need second-level freshness, check how long your engine caches the current snapshot, and whether you can turn that down.

Cold reads

Fresh data is, by definition, not in anyone's cache yet. Cold-read performance matters more for realtime tables than warm benchmarks suggest.

Three patterns for realtime SQL on Iceberg

1. Stream through Kafka, commit every few minutes

This is the most common setup and the one most vendor pages describe. It fits event streams that already live in Kafka. Expect freshness in minutes unless you tune the commit interval and add compaction to keep up.

2. Stream Postgres changes directly, without Kafka

For application data in Postgres, a CDC tool can read logical replication and commit to Iceberg directly. See our comparison of Postgres to Iceberg CDC tools. Freshness ranges from sub-second to minutes depending on the tool and its settings.

3. Write rows straight into Iceberg from your service

When the data starts in your application rather than in Postgres, append rows to the Iceberg table directly. In hosted Contrast, services can append micro-batched rows to tables over HTTP. Concurrent requests to the same table coalesce into a single Iceberg commit and are visible to queries immediately (Lakeserve docs).

How Contrast does it: Flow plus Lakeserve

If you want a Postgres insert to show up in the next Iceberg query in about a second, use Flow with Lakeserve. Contrast pairs two open-source pieces, both under Apache-2.0 and written in Rust:

  • Contrast Flow copies your Postgres tables into Iceberg, then streams every insert, update and delete as it commits. One process reads the WAL, journals each transaction, writes Parquet and commits to Iceberg. It compacts small files in the same process while changes keep publishing. It doesn't support partitioned source tables or Iceberg partition specs, and it has no high availability.
  • Lakeserve is a SQL database for Iceberg tables. Single-row inserts commit in milliseconds, and the next query sees them. It plans Spark SQL with Apache DataFusion, runs on Arrow, and in a cluster caches table data on workers' local NVMe (Lakeserve docs). Data stays in standard Iceberg tables that Spark, Trino and DuckDB can read.

On a laptop, the whole loop takes three commands:

curl -fsSL https://lakeserve.contrastdb.com | sh
lakeserve start
lakeserve client --query "CREATE TABLE trips (id BIGINT, city STRING, fare DOUBLE)"
lakeserve client --query "INSERT INTO trips VALUES (1, 'Oslo', 12.5), (2, 'Lima', 7.0)"
lakeserve client --query "SELECT city, sum(fare) FROM trips GROUP BY city"

Flow's demo shows the Postgres side: a row updated in psql shows up in Trino's next read of the Iceberg table.

git clone https://github.com/contrastdata/flow.git
cd flow
docker compose -f demo/compose.yaml up --build -d

How fast are the queries?

On ClickBench (43 queries over a 100-million-row table in Iceberg on S3), the Lakeserve team's own single-node runs give these totals:

Engine (single node, 64 vCPU class)Cold totalWarm total
Lakeserve11.79 s3.83 s
DuckDB on Iceberg13.77 s8.52 s
ClickHouse on Iceberg21.85 s5.57 s
Snowflake Large26.43 s19.27 s
Databricks SQL Serverless Medium56.28 s29.75 s

These are self-run results produced by the Lakeserve team, not an independent party. Snowflake and Databricks read their own managed copies of the data, and each engine ran on the versions and settings shown in the methodology. The methodology also notes that some DuckDB result hashes differ from Lakeserve's and that review is pending. Full results are at contrastdb.com/bench.

A note on maintenance: Lakeserve on its own leaves compaction, snapshot expiry and orphan-file removal to Spark or your catalog's table optimizers. When you use it with Flow, Flow compacts the tables it writes. On hosted Contrast, Contrast stores the tables and keeps them in sync with your sources.

How to measure freshness yourself

  1. Add a column, or use an existing timestamp, that records the source commit time.
  2. Insert a row in Postgres and poll the Iceberg table with your real query engine until it appears. Record the gap.
  3. Repeat under steady write load for an hour, and report p50 and p95, not the best run.
  4. Count data files and delete files per table at the end. If the counts keep climbing, query latency will too.
  5. Run your actual dashboard or lookup queries during the test, not only count(*).

FAQ

Is Apache Iceberg suitable for realtime analytics? Yes, with the right writer and reader. Iceberg makes a commit visible to all readers at once. The limits come from commit frequency, small files, delete handling and engine metadata caching, not from the format.

How often can you commit to an Iceberg table? As often as your catalog and writer can handle, down to sub-second. Each commit adds files and metadata, so frequent commits need continuous compaction.

Do I need Kafka for streaming into Iceberg? No. For Postgres sources, CDC tools such as Debezium Server, Flink CDC, pg2iceberg, Moonlink and Contrast Flow read logical replication and write Iceberg directly.

Why are my Iceberg queries slow after streaming ingestion? Usually because of small files and unmerged delete files. Compact data files, convert or rewrite equality deletes, and expire old snapshots.

Does Iceberg v3 help with realtime CDC? Yes. Deletion vectors in v3 are cheaper to read than equality delete files, which matters for update-heavy streams.

How fresh is Contrast? Lakeserve sees single-row inserts in the next query, with commits in milliseconds. Flow's load tests report p95 of 0.48 to 0.93 seconds from Postgres to Iceberg in 4 of 7 tests.

Try it

Get new posts by email.

Launches, open-source releases and research from the Contrast team, sent when they’re published.