News for hackers. Stuff that matters.
Re:Directly running DuckDB queries on data stored in SQLite ... by wenc on Friday March 25, 2022 @06:17PM (#30807541)
Exciting stuff!

I’ve been using duckdb instead of Pandas these days because it’s much faster on larger datasets plus I can write more compact and complex SQL than I can Pandas constructs. The fact that duckdb can query in memory Pandas dataframes faster than Pandas itself is a plus.

It’s like having a local performant database engine that can query and join across Parquet, CSV, Pandas and now SQLite.

Kinda like a quick efficient local Spark.

Re:Directly running DuckDB queries on data stored in SQLite ... by tanin on Friday March 25, 2022 @10:21PM (#30808745)
I've built an offline desktop for this: https://superintendent.app

It is a wrapper on Sqlite, but I'm looking to switch to duckdb because its dialect is more comprehensive.

Previously, I was using ruby, sometimes python, and sometimes postgresql to process CSV. But it wasn't convenient enough. Most of the times I just tried to use Excel, but formula is so hard to use.

Re:Directly running DuckDB queries on data stored in SQLite ... by nattaylor on Friday March 25, 2022 @06:00PM (#30807420)
Can't wait to see what simonw comes up for using this with datasette!
Re:Directly running DuckDB queries on data stored in SQLite ... by simonw on Friday March 25, 2022 @06:44PM (#30807709)
Setting up a plugin hook that lets you use alternative database backends is getting more and more tempting...
Re:Directly running DuckDB queries on data stored in SQLite ... by notRobot on Saturday March 26, 2022 @12:07AM (#30809157)
Like PHP PDO? https://www.php.net/manual/en/book.pdo.php

Or are you talking about something else?

Re:Directly running DuckDB queries on data stored in SQLite ... by samwillis on Friday March 25, 2022 @06:30PM (#30807622)
This would be super useful for something I’m working on using datasette, querying across three tables with over 1.5m rows. Going to try the same queries on this tomorrow.
Re:Directly running DuckDB queries on data stored in SQLite ... by 41b696ef1113 on Friday March 25, 2022 @09:55PM (#30808646)
Exactly what I have been hoping to see as well. Analytical queries are a tad too slow for datasette, so I have had to materialize the more interesting roll-ups.
Re:Directly running DuckDB queries on data stored in SQLite ... by mastax on Friday March 25, 2022 @07:03PM (#30807829)
I really like the DuckDB philosophy, and the maintainers were really responsive and helpful with my docs questions. Didn't end up using it because the compressed database files were much larger than SQLite for my data (weird use case, admittedly), and the .NET libraries were poor. I look forward to trying it out again, though.
Re:Directly running DuckDB queries on data stored in SQLite ... by wenc on Friday March 25, 2022 @09:02PM (#30808411)
> the compressed database files were much larger than SQLite for my data

Just curious, what format did you use?

If it's Parquet, it does column compression via Snappy by default (which more optimized for speed than size).

You can change the compression to ZSTD or GZIP for higher compression ratios.

https://duckdb.org/docs/data/parquet

Re:Directly running DuckDB queries on data stored in SQLite ... by mastax on Friday March 25, 2022 @11:25PM (#30809005)
I tried all of the available compression formats in parquet, natively in duckdb, and compressing raw duckdb files as a whole. IIRC just GZIPing SQLite files beat them all. The SQLite files were much smaller uncompressed (~220mb vs 800mb) which was probably most of the difference.
Re:Directly running DuckDB queries on data stored in SQLite ... by pletnes on Saturday March 26, 2022 @07:39AM (#30810993)
Can you still query a gzipped sqlite file? What’s the sense in gzipping it if not?
Re:Directly running DuckDB queries on data stored in SQLite ... by floydnoel on Saturday March 26, 2022 @01:02PM (#30813462)
Do other formats (Snappy?) allow this?
Re:Directly running DuckDB queries on data stored in SQLite ... by wenc on Wednesday March 30, 2022 @10:39AM (#30855821)
You can also query gzip and zstd parquet files directly.
Re:Directly running DuckDB queries on data stored in SQLite ... by benglish11 on Saturday March 26, 2022 @02:43PM (#30814206)
You can query snappy parquet files directly.
Re:Directly running DuckDB queries on data stored in SQLite ... by ignoramous on Saturday March 26, 2022 @03:27AM (#30809986)
> ...the .NET libraries were poor.

DuckDB's Node bindings leave a lot to be desired, as well. WASM bindings have a different API surface, too. From my reading of the code and docs, it looks like duckdb 3p bindings for anything other than python is in dire need fit and polish.

Re:Directly running DuckDB queries on data stored in SQLite ... by ankoh on Saturday March 26, 2022 @01:32PM (#30813665)
We're still on a journey to explore what APIs work best with JavaScript but the differences between WASM and Node are on purpose. DuckDB-Wasm has isolated wasm heap memory and runs in a separate web worker. That's why we serialize everything as Arrow IPC buffer and pass the ArrayBuffer through the workers message API as transferrable. On Node.js, we can interact with DuckDB much more easily and don't want to pay the price for the IPC stream every time. The truth is, we tried quite a few different APIs and this turned out the be a good trade off between efficiency and convenience.

But I'm happy to discuss this further if you have any suggestions.

Re:Directly running DuckDB queries on data stored in SQLite ... by zX41ZdbW on Friday March 25, 2022 @07:32PM (#30807969)
ClickHouse can do this since maybe a year already: https://clickhouse.com/docs/en/engines/database-engines/sqli...
Re:Directly running DuckDB queries on data stored in SQLite ... by wenc on Friday March 25, 2022 @08:58PM (#30808394)
ClickHouse is a full DBMS server.

DuckDB, similar to SQLite, is an in-process query engine for local data.

Re:Directly running DuckDB queries on data stored in SQLite ... by zX41ZdbW on Friday March 25, 2022 @09:27PM (#30808524)
ClickHouse can also run as a query engine for local data, see clickhouse-local.
Re:Directly running DuckDB queries on data stored in SQLite ... by samwillis on Friday March 25, 2022 @06:26PM (#30807597)
Would love to see a benchmark comparing SQLite, DuckDB and this SQLite/DuckDB combo with the same queries and data.

Is this adapter copying the contents of the SQLite db into DuckDBs own memory layout in order to optimise the queries or is it just “proxying” to the SQLite library?

Re:Directly running DuckDB queries on data stored in SQLite ... by 1egg0myegg0 on Friday March 25, 2022 @06:55PM (#30807780)
It is just scanning the data (in parallel), not copying it into DuckDB!
Re:Directly running DuckDB queries on data stored in SQLite ... by eatonphil on Friday March 25, 2022 @06:34PM (#30807642)
I'm excited to use duckdb in DataStation/dsq but the Go bindings aren't yet super mature and I haven't had time to work on them myself yet.
Re:Directly running DuckDB queries on data stored in SQLite ... by SuaveSteve on Saturday March 26, 2022 @07:25AM (#30810919)
We have too many database products.