# Node-red unresponsive while sqlite node is working

**URL:** <https://discourse.nodered.org/t/node-red-unresponsive-while-sqlite-node-is-working/63465>\
**Category:** General\
**Created:** [4 June 2022 19:36 UTC](https://discourse.nodered.org/t/node-red-unresponsive-while-sqlite-node-is-working/63465 "2022-06-04T19:36:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonntam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sonntam/32/19423_2.png) [@sonntam](https://discourse.nodered.org/u/sonntam)\
**Post date:** [4 June 2022 19:36 UTC](https://discourse.nodered.org/t/node-red-unresponsive-while-sqlite-node-is-working/63465/1 "2022-06-04T19:36:43Z")

</div>

I'm using the sqlite-node extensively to store and retrieve sensor data. So far I have around 20 different sensors (temperature, humidity, co2-concentration, air pressure, open/closed status,...) that push data into a sqlite3 database. The database is stored on a fast ssd and currently has around 260 MBytes of size (data has been collected for the past 2 years).

Every 30 minutes I update my dashboard charts with the collected data from the sqlite3 database, presenting the last 18 hours of data. It takes around 600ms for each data series to be retrieved via the sqlite node. In total around 40 seconds of cpu time is needed on one core to retrieve all data I want to display.

Now here is my problem: While the sqlite node is working the node-red flows are completely locked up and I see that the node-red process is busy 100% on one of the 4 cpu cores. During the time of the data retrieval I can't open dashboard or the flow editor.

Is there anything I can do to keep node-red responsive while the sqlite node is busy? The only idea I have right now is using the exec node and manually using the sqlite3 cli program. This way a separate process would be spawned that can run on another core/thread.

Is there any other more convenient way?

I'm using Node-Red 2.2.2 with the node-red-node-sqlite 1.0.3 node.

---

<div class="post-metadata">

**Author:** ![sonntam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sonntam/32/19423_2.png) [@sonntam](https://discourse.nodered.org/u/sonntam)\
**Post date:** [4 June 2022 21:18 UTC](https://discourse.nodered.org/t/node-red-unresponsive-while-sqlite-node-is-working/63465/2 "2022-06-04T21:18:39Z")

</div>

Well,... sometimes I can't stop tinkering. I implemented a custom `exec async` node that uses node.js `childProcess` and `stream` libraries to start a process and pipe text to its stdin.

This custom node is used in a custom `sqlite read async` node to spawn a niced (to decrease process priority) `sqlite3` cli process which opens a sqlite db with the `-readonly -json` flags.

This works quite nicely. Note that you have to have the `nice` and `sqlite3` programs on your path in order for this to work. The sqlite file path cannot contain `~` as the path is put in double quotes, but you can use the `$HOME` env variable.

[Gist for custom sqlite read async node.](https://gist.github.com/sonntam/7ea3226d2fc0b078c59130af7eb4b494)

---

<div class="post-metadata">

**Author:** ![sonntam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sonntam/32/19423_2.png) [@sonntam](https://discourse.nodered.org/u/sonntam)\
**Post date:** [9 June 2022 21:18 UTC](https://discourse.nodered.org/t/node-red-unresponsive-while-sqlite-node-is-working/63465/3 "2022-06-09T21:18:03Z")

</div>

The aforementioned `exec async` node with the ability to pipe in stdin to a process has proven (at least in my case) to be quite useful. I might consider writing up a proposal to extend the core "exec" node.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 August 2022 21:18 UTC](https://discourse.nodered.org/t/node-red-unresponsive-while-sqlite-node-is-working/63465/4 "2022-08-08T21:18:58Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
