This is an interesting thread as this week I received an email from my ISP informing me I had a large number of sleeping mysql connections (and could I take steps to reduce the number).
I'm using 'node-red-node-mysql' which seems to keep each connection open after the query has been executed (so I can see how that would annoy my ISP when the number becomes significant).
This morning I installed mysql (mariadb) on one of my RPi-4B home-servers and created a local and some remote users.
By using SHOW PROCESSLIST; (when logged in to mysql) I can see that 'mysql' leaves each connection open after it has executed the query, and can see why this might annoy my ISP, as in my case I suspect the number was quite high.
The 'mysql2' node closes a connection after execution and never appears on the Processlist.
I've actually run a flow all morning, that pings devices around my home, and then performs a series of INSERT queries every 90 seconds (to my local server) and not encountered any problems.
If you are going to develop an application where every time you need to insert a record in an external database, such as capturing data from telemetry, where there are thousands of records, imagine and this opens and does it close all the time of the connection?
For sure the performance will not be the same...
Even more so in professional applications
I'm developing an application that will add at least 10,000 records in about 5 minutes.
I can't plan something that will open and close the connection every time I insert.
If I choose to open and close the connection all the time, it will consume a lot of machine resources
is that 10000 records EVERY 5 minutes? You do realise the database have 2,880,000 new records per day, 1,051,200,000 new records per year (1,051,200,000 = one billion fifty-one million two hundred thousand)
The node-red-node-mysql node uses a connection pool (as do many / most applications).
Database connection pooling is a way to reduce the cost of opening and closing connections by maintaining a “pool” of open connections that can be passed from database operation to database operation as needed
PS, would you mind not tagging please directly (we are all volunteers here and respond when we can) - thanks.