Closed
Description
There are definitely some queries that I need to run that are quite slow and I cannot lock up my server for everyone while a user wants to run a slow query. So I'm looking at the worker threads option, but it seems like that's generic enough to be included as a utility within better-sqlite3. Something like this?
import { asyncQuery } from 'better-sqlite3'
asyncQuery('foobar.db', 'SELECT COUNT(DISTINCT "userId") FROM "PostRead" WHERE "userId" IS NOT NULL')
The main difference in what I'm suggesting from what's in the docs is that you'd pass the database file as the first parameter so the worker file could be made more generic. But I'm pretty sure that should work.