LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DB tools open connection takes 300ms each time - best practice?

Hello I have a fairly large LV2015 application that reads many times (>100) from database. So far I have used a vi with open-execute-fetch-close for each mysql query.

 

I have spent some time to make the slowest mysql queries faster, using the mysql profiling.
But when I now finally profile in labview (by saving exact times to an event file) I see that each open (DB tools open connection.vi) seems to take about 300ms. If I then have 100 queries this really adds up to a lot of time...

 

So what is best practice here, shall I have one open connection all the time, assuming it stays open for ever (a user might work 2-3h at a time with the program).

Another idea is to do some kind of check if the connection is still open, before each query, and only open if not.

A third is to assume is stays open, and redo the query with Open if I get error messages.

 

I guess you guys have some good advice here!

 

I might add that the database has moved from within the same office to another office, making the problem worse.

Labview 2015, mariadb 10.1

 

 

0 Kudos
Message 1 of 3
(2,116 Views)

You already figured out. My preferred is the third option, however the second is not much different.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 3
(2,101 Views)

@pincpanter wrote:

You already figured out. My preferred is the third option, however the second is not much different.


Ditto that!

 

Add "possible memory leak" from repeatedly opening and closing a resource (that will only show up in the Task Manager since the DB is outside the LV context).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 3
(2,062 Views)