Why we built Moraine
At Contour we build analytics pipelines for multi-location businesses, mostly in hospitality. We keep data as granular as we can so we can generate specific, actionable insights, and with thousands of orders a day per location, plus a whole host of other events, data volumes can add up.
For security and privacy, every business gets its own lake: one ingest service that refreshes it at intervals, and read traffic that is spiky and has to scale. Between refreshes the lake often sits idle. We moved these to DuckLake to get out from under commercial warehouse pricing and because it’s a great open spec. Our customers don’t have the margins to fund expensive commercial data infrastructure at today’s prices.
But after moving to DuckLake, we discovered that the part that didn’t fit with our use case was the catalog.
A database per lake
Section titled “A database per lake”DuckLake’s core idea is that the metadata lives in a SQL database. On a laptop that’s a DuckDB file. In the cloud it has to be a server: Postgres, or DuckDB behind Quack. We keep each client’s data and metadata apart, so one client’s lake can be copied, audited, or removed without touching another’s. One Postgres shared across clients would have undone that, so it was a database per lake, each billed around the clock despite only intermittent access patterns. We tried Neon, and between bandwidth and scaling compute for peak workloads, the bill got expensive quickly.
The data was already in a bucket that costs nothing while idle and scales without us doing anything. The catalog was the one piece that didn’t work that way. So how could we change it?
What the catalog actually needs
Section titled “What the catalog actually needs”After more exploration, we found that DuckLake’s wise move to a database could be reduced to what the catalog actually needs: transactions, so a commit lands or doesn’t; ordered reads, so it can list a table’s files or walk a snapshot’s history; and somewhere to inline small inserts and deletes until they can be batched into a Parquet file. It doesn’t need the full set of Postgres features.
SlateDB provides that, and it keeps its state in object storage: a write-ahead log, sorted files, and a manifest, all objects in a bucket. It’s embedded, so there’s no server, and its manifest carries a writer epoch, so a stale writer can be fenced off.
Didn’t Iceberg try this?
Section titled “Didn’t Iceberg try this?”We were admittedly naive about the state of open-source lake architecture when we started. As we did more research, we found that Iceberg and Delta Lake had both explored this path. Iceberg’s original file-only catalog was the same idea, metadata in the bucket with no service, but it commits by renaming a file, which S3 can’t do atomically, so two writers could both believe they had won. It was never safe on S3, and the project moved to catalog services instead. S3 added conditional writes in 2024, and that’s what makes SlateDB’s fencing safe on S3. Moraine also isn’t a catalog made of files. There’s still a database in the loop. It’s just embedded, and it lives in the same bucket as the Parquet.
Delta Lake is closer. Each table is a directory with its own log, and a commit is a put-if-absent of the next entry, so any number of writers can commit. But the format stops at the table: there is no transaction across two tables, and there’s no inlining, so small writes mean small files. We rely on cross-table transactions and inlining both.
How it works
Section titled “How it works”Moraine implements DuckLake’s full catalog interface on SlateDB. DuckLake still plans queries and runs transactions; SlateDB serves its metadata tables row for row.
A commit is one SlateDB transaction, applied in one atomic batch that writes the pointer to the current snapshot. Two commits that race collide on the pointer and the loser is sorted out by DuckLake’s own conflict rules.
The commit is acknowledged once the write-ahead-log entry is durable. On S3 that’s about 36 ms for a single-row commit. With the write-ahead log on S3 Express it’s about 10 ms, on par with a local DuckDB file at 11 ms and ahead of Postgres at 14 ms.
One process holds the lake read-write. Every other process connects read only, follows the writer’s log, and can run anywhere with bucket credentials. A reader picks up new commits on a poll, every ten seconds by default. The newest writer always wins, so if two overlap during a deploy the old one fails on its next commit and nothing is corrupted.
At Contour, a significant portion of what we ingest is a newer version of data
we already have. Without an index, that meant finding those rows involved
scanning every file whose column statistics couldn’t rule it out. So we added
index support using SlateDB’s key-value store. CREATE INDEX on a column builds
an ordered index whose entries land in the same commit as the rows, so the
lookup reads only the files that hold the key.
What it costs
Section titled “What it costs”Connection time is the biggest drawback compared with the other catalogs. A fresh process takes about 700 ms to connect, against 17 ms for a DuckDB file and about 190 ms for Postgres. That cost is paid once, and it buys a lot: once connected, a count comes back in 4 ms against 29 ms for a DuckDB file and 51 ms for Postgres, and a full scan from a fresh process takes 11 ms against 39 ms and 62 ms. Moraine suits a service that connects infrequently and stays connected.
The other limitation is that only one process can write to a lake at a time. If you need many independent writers, DuckLake on Postgres is still the right call, with the same tables and the same Parquet. If one service per lake does the writing, as in our case, this is fine, and you can still use DuckDB to join across lakes downstream when you need to combine domains.
Where it is
Section titled “Where it is”Moraine runs all of DuckLake’s SQL: cross-table transactions, time travel, the change data feed, schema evolution, maintenance. We verify it differentially against a stock DuckLake catalog. It’s in production on our clients’ lakes and it’s still alpha software. We plan to keep it current as DuckDB and DuckLake progress.
What’s next
Section titled “What’s next”Next up are online index rebuilds (today a rebuild is DROP INDEX then
CREATE INDEX, with no index in between), Windows builds, and shaving
DuckLake’s per-commit overhead, most of which is DuckDB re-planning the
catalog SQL.
If you try it, what we most want to hear about is workloads where it breaks down. Open an issue or start a thread in Discussions.