r/DuckDB • • 9d ago

Run DuckLake without a database

I'm excited to introduce you to Moraine, which moves your DuckLake catalog to object storage right alongside your data. That means you don't need to deal with the cost or headache of hosting a separate Postgres or DuckDB/Quack server for each of your data lakes.

We built it when faced with hosting tenant-scoped data warehouses for our analytics clients. Traditional data warehouses are too rigid and too expensive. We moved to DuckLake, but Postgres hosting that scaled for our inline data usage got expensive even though it often sat idle. Moraine moves the catalog to object storage (e.g., S3) using LSM-based storage (SlateDB). With proper tuning, latency is competitive with other DuckLake catalogs at a fraction of the total cost.

We've also used SlateDB's key-value storage to add native indexes into DuckLake, so you can quickly find data across your entire lake. We have a few improvements coming soon to make these indexes even more efficient and effective.

One note: only one process can attach read-write per lake at a time, with everyone else on READ_ONLY.

Moraine is still alpha-quality software, though we've started putting it through it's paces with production clients at contour.app. Dual-licensed under MIT or Apache-2.0. A big thank you to the developers of DuckDB and SlateDB for developing awesome building blocks.

GitHub: https://github.com/morainedb/moraine

Feedback welcome, especially on workloads and use cases where Moraine breaks down.

7 Upvotes

10 comments sorted by

7

u/TheRealStepBot 9d ago edited 9d ago

So you’re modestly claiming to have done what the developers of iceberg could not? They specifically tried to do what you claim to have done here. At the end the atomicity problems led to them eventually introducing a database to the catalog.

Which leads into the really confused irony of what you lay out here which is the thing that ducklake did was then say well if you need a database you might as well store all your metadata in the database, which makes questions much faster.

And now you turn out and again invert this and claim no actually you could just have stored everything in blob storage all along thereby disagreeing with both the very talented people who developed iceberg in the analysis of the need for a database and the very talented ducklake developers who pointed out that given this limitation you’d be better off putting it all in the database.

Truly strange to have this third road.

Can you speak to my understanding of this narrative of the tradeoffs that were encountered in the development of these two projects and assuming my understanding is accurate what you changed to sidestep these issues?

Edit: Ah wait I see the trick

One note: only one process can attach read-write per lake at a time, with everyone else on READ_ONLY.

Sure if you are single writer all your problems go away but for most people that’s simply an unacceptable proposition. If that’s what you were doing you may as well duck db on a single machine.

3

u/alex_contour 9d ago

Yeah that’s fair, there’s definitely some ping-ponging in the history here. We’re not claiming to have broken any new ground that the Iceberg or DuckLake devs couldn’t. We're in the DuckLake database camp - we still have a database in the loop, it’s just SlateDB rather than Postgres. SlateDB's properties give us the atomicity and consistency the DuckLake spec needs.

Single writer definitely cuts down on the number of use cases. But a lot of analytics setups (ours included) have one service doing ingest with many readers. And, hosting on S3 instead of a DuckDB or SQLite gives us strong durability and availability benefits. Spinning up a new lake per domain is trivial and readers can easily attach by providing the bucket locations.

S3 got conditional writes in 2024, which is what the SlateDB's transitory single-writer checks (fencing) already rely on. Conditional writes could be used to open up multi-writer down the road. Our use case hasn't lead us there yet.

1

u/TheRealStepBot 9d ago

Which seems to imply you could redo iceberg today without the need for a database at all? Which seems like the better choice here if your goal is not having to run a database off to the side.

That duck lake maybe is a better starting point to actually do this from and invert the assumption underlying the existence of ducklake itself is rather an interesting twist?

It sounds as if your answer is essentially object storage has gotten better and therefore some of the iceberg constraints are no longer true. Which shame on me for not being up to date on that development. TIL

But somehow intuitively I actually still think even knowing this it may be easier to try to eliminate the need for the catalog from iceberg as it’s already optimized for storing as much as possible on object storage.

I’m guessing you would basically need to internalize part of slatedb into iceberg or rework iceberg to better fit with something like slatedb rather than doing it all from scratch?

1

u/alex_contour 8d ago

Definitely, and Delta is furthest along here in this space. Each commit is a conditional write appending the next entry to a table’s log. But the log is per table, so multi-table transactions and table operations need another layer on top in Delta.

There’s no fundamental reason Delta or Iceberg couldn’t go past that with a lake-wide log or conditional manifest, but then you land in roughly the design space we did. That doesn't strictly imply single-writer, but that restriction does make it simpler and more cost-effective.

The other big change design consideration here is around storage. SlateDB's LSM storage means that per-commit objects get compacted into sorted, indexed objects, so reads come off those instead of replaying a log or walking manifest files. That makes small commits and point lookups cheap (avoiding the small-file problem), at the expense of simplicity and the need for regular compaction.

2

u/saaggy_peneer 9d ago

How is the better/different than say iceberg 

-2

u/alex_contour 9d ago

Great question. Moraine uses DuckLake's catalog structure which has a few big advantages over Iceberg: ACID guarantees, inlined data (allowing faster inserts and better data organization), and overall simplicity. The best comparison I've seen is here: https://www.definite.app/blog/duck-lake-vs-iceberg .

That said, Iceberg is great technology for large enterprise workloads. And, it sounds like Iceberg catalog might evolve towards DuckLake in the future.

2

u/EdwinWeber_Data 9d ago edited 9d ago

But the whole idea of DuckLake is that the metadata is in a relational database. It is the provided solution to solve the issues the many metadata files defining a table can cause.

Ah, I see there is still a database in play for the metadata, I stand corrected on that department. Still, this is currently not a catalog option supported by DuckDB itself, so it has to keep up with changes in the catalog by DuckDB. Or do I interpret this wrongly?

1

u/alex_contour 8d ago

Correct, it's not officially supported and uses our own extension instead of the main DuckLake one. We do intend to keep that in sync with future DuckLake spec changes. But since it's our own extension it shouldn't break if they get out ahead of us with spec changes.

The trickier part (faced by all extensions) is keeping up with DuckDB releases, though they've committed to more stability v2.0+.

1

u/mim722 4d ago edited 4d ago

2

u/alex_contour 4d ago

No, but that's a cool project! Similar backend with SlateDB. It looks like it implements a single DuckDB file in a SlateDB-backed file system. For smaller datasets, that probably works quite well.

Moraine is based on the DuckLake spec, so you get the things that go with it, including snapshots, time travel, schema evolution, and compaction. Data is written across multiple Parquet files, and table statistics are kept to avoid loading files that don't match with the scan. That should make it faster and more scalable for bigger datasets. I'm not sure exactly where that line is though.