I'm using data from the database to update multiple screens every 5 min from the database.
To do this, I need to run several queries in the same database.
What is the best practice, make a flow for every query with his own MSSQL node, like this example (the query is in the inject node):
I haven't tried the second way so I don't know if this works.
I noticed that having multiple MSSQL nodes that are triggered at the same time causes problems.
Typically, I would not do this in parallel - but even more-so not with the OLD, less capable, very buggy, potentially dangerously out-of-date MSSQL node.
Make sure you are using the in-support, up-to-date node-red-contrib-mssql-plus node
As for other recommendations, don't use {{var}} syntax in your queries - always use parameters (to avoid risk of SQL injections)
I concur with @Steve-Mcl that it is not a good I idea to trigger concurrent queries. What I always do is define a generic node-group which is reused across all flows via link-calls.
In that group I put some standard protection & error management, e.g., a rate limiter (ensuring a minimum "breather" between queries), error catching/handling, retries etc.
And... be sure to observe the best practices for query creation and execution... injection attacks for example can be a key issue using SQL. Never hurts to structure SQL queries so they are not obviously vulnerable.
Thank you all for the input, where some very good idea's.
I installed the newer node-red-contrib-mssql-plus and found it a very good idea to build a subflow for connecting to the database. This way I have only one place to be if something changes. But I don't really know how to optimize it, so I build something simple like this:
when you put a node like this (in a subflow) each instance of the subflow will create a separate connection to the database. If this is azure, you can easily hit connection limits.
You are better off using link-call as pointed out by @omrid
What is the best place to put the group? I have it now on my flow, but I have multiple flows. Do I make a flow only for this one, or can I still put it in a subflow? (or is it than creating multiple connections)
The status (like here done), can I show it in the link call.
I know, a lot of questions but I try to get it right from the first time.
Thanks
You can place the node-group anywhere you wish (even in its own tab) and call it from any flow tab in the editor. I recommend calling the entry point (link-in) of the group it with a dynamic address (msg.target), not by node Id, to protect against Id changes (import, copy/paste etc.).
I am not familiar with a way to show status on a link-call. @Steve-Mcl ?