Hacker News new | ask | show | jobs
by eatonphil 1778 days ago
sql.js is pretty hard to use as is otherwise you run out of memory really quickly. I was trying to use it as the in-memory SQL flavor for an open source data ide [0] but my naive approach of `SELECT * FROM VALUES (...), ...` would run out of memory after only a few hundred rows.

I ended up switching to https://github.com/agershun/alasql which could handle up to 80MB of data or so. (I haven't yet tested on larger datasets so I don't know the actual limits.)

I don't think this is a fundamental limitation of sql.js as the linked article proves that you can implement custom paging for sql.js. But unless you do that (which I haven't spent the time to figure out how to do) then sql.js will run out of memory very quickly.

Just something to be aware of if you're investigating it.

If there's a high-level library that makes more effective use of memory with sql.js under the hood let me know.

Unlike absurd-sql I don't need the results to be permanent. I just wanted an in-memory SQL for joining, filtering, grouping data.

[0] https://github.com/multiprocessio/datastation

3 comments

Something sounds wrong with your setup. I've had no problems!
Emscripten wasm binaries with memory growth enabled can use up to 2 GB heap. That's very surprising that you're hitting a memory limit.
When did you make your tests, and with which browser ? Did you use a prepared statement to fetch your results ?

Raw sql.js is limited by the browser's wasm memory limit, but 80Mb should not cause an issue...