Live data from Hacker News

DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

duckdb.org

21–30 of 167 posts

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#21
post #18

Say I want to fix logistic Regression. Can I do that in database? Or have to extract it out as a dataframe? Cna I stream the data?

If you want to do linear regression aggregations with any DB, one thing you can do is store the coifficents and then aggregate them on request. You sacrafice some accuracy for speed.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#22
I spent a while looking at this today. It's really interesting.

It's not based on SQLite at all (except for borrowing the SQLite shell implementation) but it looks very much like SQLite, in particular:

- It's designed to work as an embedded library, eliminating the network overhead you usually get when talking to a database

- Each database is a single file on disk

- It ships as an "amalgamation" build - a single giant C++ file (SQLite is a single giant C file)

Impressively, if you run "pip install duckdb" it Just Works - you can then "import duckdb" and start using it, with an interface that looks very similar to the sqlite3 module that ships with Python.

The key reason this exists is that it's a column store, with vectorized operations across columns - making it ideal for analytical workloads. This blog entry has some benchmarks that illustrate how well it works in that regard: https://uwekorn.com/2019/10/19/taking-duckdb-for-a-spin.html

It's also backed up by some strong computer science. It's by the academic researchers behind MonetDB and includes implementations of a bunch of interesting papers: https://duckdb.org/docs/why_duckdb#standing-on-the-shoulders...

It's a really interesting piece of software, and unlike many other "new databases" it feels like it fills a very genuine gap in my toolbox.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#23
post #6
post #2

I was hoping from the title that it aims for postgres SQL compatibility, but I can't find it explicitly mentioned in the docs. This really makes me think I really want something like sqlite://memory which completely disregards speed or even persistence. Instead you could say for example "open an in-memory database that behaves like postgres 9" and run your tests against it. With typical fixtures of 10 or so rows, you…

Man, I’ve wanted the “compatible SQL engine with only RAM storage” for testing for YEARS. Closest I got was some shenanigans with MSSQL’s LocalDB.

I'd build this, but I'm not sure if I'd be able to get anyone to fund it.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#24
post #12

Earlier quoted context omitted.

Foreign keys enabled by default or by configuration setting would be another big feature missing from SQLite3, but I couldn't find any mention of foreign keys in DuckDB's documentation.

It doesn't look like it provides FK looking at the create table syntax. Just PKs, unique, and check on an expression similar to sqlite.

What? SQLite3 absolutely has FKs.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#25

Earlier quoted context omitted.

Those solutions still have a high overhead. There's acid compliance, serialisation in memory, maintaining indices, and many other layers. Compare it to an ideal testing solution with no initialisation cost and insert being literally: parse the query, add a new entry to a list, done.

But you want to be testing against something that is as close as possible to the deployment environment. So if that means acid, indices etc, then that's what it is.

You can still do them in a trivial way that works like production. For example: if some column has a unique index, look at all rows and compare the new value. You don't need an actual index for it. (And definitely not a fancy concurrent access btree) For transactions/mvcc you can literally make a copy of everything.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#26
post #12
post #4

Strict typing has been the one big feature missing from SQLite, that this presumably brings.

Foreign keys enabled by default or by configuration setting would be another big feature missing from SQLite3, but I couldn't find any mention of foreign keys in DuckDB's documentation.

SQLite has foreign keys, but they are disabled by default for backwards-compatibility reasons. https://sqlite.org/foreignkeys.html

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#27

Earlier quoted context omitted.

It doesn't look like it provides FK looking at the create table syntax. Just PKs, unique, and check on an expression similar to sqlite.

What? SQLite3 absolutely has FKs.

You just have to write

    PRAGMA foreign_keys = on;
each and every single time you want to do an operation that requires an FK constraint, like `INSERT`.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#28
post #26
post #12

Earlier quoted context omitted.

Foreign keys enabled by default or by configuration setting would be another big feature missing from SQLite3, but I couldn't find any mention of foreign keys in DuckDB's documentation.

SQLite has foreign keys, but they are disabled by default for backwards-compatibility reasons. https://sqlite.org/foreignkeys.html

And it's not possible to enable them by default - there is no existing configuration setting to override that design choice. They hope to include the feature in SQLite4, as I understand it.

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#29
post #21
post #18

Say I want to fix logistic Regression. Can I do that in database? Or have to extract it out as a dataframe? Cna I stream the data?

If you want to do linear regression aggregations with any DB, one thing you can do is store the coifficents and then aggregate them on request. You sacrafice some accuracy for speed.

Model fitting. How to do?

Re: DuckDB – An embeddable SQL database like SQLite, but supports Postgres features

#30
post #22

I spent a while looking at this today. It's really interesting. It's not based on SQLite at all (except for borrowing the SQLite shell implementation) but it looks very much like SQLite, in particular: - It's designed to work as an embedded library, eliminating the network overhead you usually get when talking to a database - Each database is a single file on disk - It ships as an "amalgamation" build - a single gian…

I really appreciate the breakdown here but this comment smells like a giant plant for DuckDB.
Post reply on HN