I am liking the simplicity of the better-sqlite3 Nodejs library, but it is
synchronous (for some good reasons), so it will hang the main thread until
sqlite is done.

I would like to make it partially asynchronous, still doing most of the
work on the main thread, but waiting in a helper thread. I was thinking
that the longest delays will be from disk access, so sqlite_step().

The idea is to call sqlite_step() in a thread and then wait for the main
thread to copy the result into JS values (JS memory is not threadsafe),
then wait again and so on.

I wonder, is it only the first _step() that takes a really long time, doing
the query planning and index reads etc, and the rest is reading mostly from
buffered data? That would allow reading all the values in the main thread,
after the initial wait, or maybe per 10 rows or so.

Ideally there'd be some way to know if a _step() call will be served from
buffer…

Are the above assumptions correct? Any other calls (besides opening the db)
that can take a long time?
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to