From 7b3fec382df2766fa037e8e89302ed2d305c17f2 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Wed, 30 Nov 2022 10:38:24 -0700 Subject: [PATCH] add reference to piscina Closes #914 --- docs/threads.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/threads.md b/docs/threads.md index da45b5b8..1d49b01e 100644 --- a/docs/threads.md +++ b/docs/threads.md @@ -2,6 +2,8 @@ For most applications, `better-sqlite3` is fast enough to use in the main thread without blocking for a noticeable amount of time. However, if you need to perform very slow queries, you have the option of using [worker threads](https://nodejs.org/api/worker_threads.html) to keep things running smoothly. Below is an example of using a thread pool to perform queries in the background. +NOTE: The example below is nice for simple use cases, but if you're going to do anything much more complex, then you may want to look into a proper worker library like [piscina](https://github.com/piscinajs/piscina). + ### worker.js The worker logic is very simple in our case. It accepts messages from the master thread, executes each message's SQL (with any given parameters), and sends back the query results.