Advice needed on mysql / for loop

#1

I need some advice how to handle the data in the best way

i get reservations from a xml, then i loop trough it with a for loop.
then on every step i use node.send to output the values.
these values i want to check with another local database and if they do not excist and want to add them.

but the output is really fast going :wink:

can i just forward this output to a script and then to a sql node?
is there a buffer for this?

Thanks

0 Likes

#2

What do you mean by a script? If you mean nodes such as function nodes then you should be ok. The speed should not be an issue as each message will be handled before the next one gets processed. It will run at whatever speed your processor and database can handle. Node red is single threaded so it will handle them one after another.

0 Likes

#3

Thanks Colin,

Yes i mean a function node.

So pretty cool!
You made my day :wink:

Have a nice weekend!

0 Likes

#4

If trying to optimise speed. Don't forget that the insert logic in the db may become the slowest part. You may wish to consider trying to batch your inserts, so collect a load of inserts and send them to the db all at once.

0 Likes

#5

you can also get the db to check to see if it exists and only add if it doesnโ€™t

http://cc.davelozinski.com/sql/fastest-way-to-insert-new-records-where-one-doesnt-already-exist

1 Like

#6

thanks TotallyInformation and ukmoose, the speed is not the problem for now.
i try the solution from ukmoose now

0 Likes