-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How open SQLite database? #62
Comments
A couple options to try:
|
// Install SQLite extension
const install = await DuckDBInstance.create();
const installConnection = await install.connect();
await installConnection.run("INSTALL sqlite;");
// Open database and create connection
const path = "../data/10m_urban_areas.mbtiles"
const db = await DuckDBInstance.create(path, {
threads: 4,
});
const connection = await db.connect(); Thanks, I managed to fix it, but queries are really slow. 0,0,0: 242.801ms
1,0,0: 235.962ms
1,0,1: 285.763ms
1,1,0: 244.896ms
1,1,1: 237.353ms
2,0,0: 234.29ms
2,0,1: 239.029ms
2,0,2: 235.906ms
2,0,3: 240.602ms
2,1,0: 238.652ms
2,1,1: 238.997ms Where on SQLite queries are 0.021ms in average. Duck db is, 10000x slower for these queries. Is this expected for SQLite extension? Or this specific query is not a good fit for duckdb? See reproduction: https://github.com/mapka-dev/mbtiles-benchmark/blob/master/duckdb-node-js/default-seq.js |
I don't have much experience with the However, looking at the queries you're running, it seems you're doing point lookups. That is, you're using a WHERE clause to find and return a single, specific item of data, rather than returning many rows or doing some sort aggregation. SQLite, as an OLTP database, is optimized for the former, while DuckDB, as an OLAP database, is optimized for the latter. Also, I don't know if it's relevant in this case, but I'd be curious why you're setting |
I am running this do benchmark and to evaluate different alternatives for database backend for mbtiles. In fact, 4 threads in this case gives DuckDB unfair advantage. I still need to implement thread pool for SQLite. From system monitor, CPU, and disk utilization is very low, I think that threads setting have very little effect. I am running this on AMD Ryzen 7 5800X with 16 logical cores. With threads 1: My guest is that there is bottleneck in node event loop or bindings that prevent from higher utilization. There is reason why better-sqlite decided to use sync interface instead of async/promise based one. Maybe for duck async interface is better in context of typical queries. WiseLibs/better-sqlite3#32 I am aware that duckdb is OLAP database, but I wanted to try for this case. |
If I modify your benchmark script to just make a simple SELECT statement (e.g. One possible explanation could be the |
Since there's no reason to suspect that the observed performance is specific to Node, I'm going to close this issue. If we do discover something specific to Node, we can open a more specific issue. I'm happy to continue the discussion, to help understand what's going on. But I'm no expert on DuckDB performance, nor the |
How to install extensions?
I am trying to open SQLite database.
I get the following error:
The text was updated successfully, but these errors were encountered: