LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

database producer consumer architecture

Dear NI supporters,
I am trying to devolope Producer/Consumer program to communicate with MS SQL database.
The Producer loop select data from database1 and process them.The Consumer loop insert proccesed data to database2.
The problem is, fast Producer loop must wait for slow Consumer loop and I have no idea why.

I have attached really simplified VI. There are two parallel processes (while loops). First loop read large data and the execution time is high. The second loop read really small data, so execution time is low. So if I execute the VI, I would expect the fast while loop (FAST PROCESS) will get much more iterations then the slow one (SLOW PROCESS). But the reallity is, the FAST PROCESS will get the same number of iteration as SLOW PROCESS. It looks like the processes don´t run in parallel or did I just missed something?
Could you explain me, why this occur, and how can I improve my code?

Thanks in advance.

0 Kudos
Message 1 of 9
(4,097 Views)

It looks like the Database Connectivity Toolkit VIs aren't reentrant, so your loops will have to share them instead of operate in parallel.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 9
(4,075 Views)

Thank you for your reply,

Yes, Database connectivity toolkit is Non-reentrant, but in my code there is any Non-reentrant VI twice, so I would expect no problem.

Or doesn´t it matter how is select process from database implemented (query VI, select VI) ??

Thanks

0 Kudos
Message 3 of 9
(4,008 Views)

Look deeper.  The Select in your top loop uses the same functions as you used in your bottom loop.

 

nonree.jpg

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 9
(3,991 Views)

Thank you Jim, it really helps me!

Do you also know any other library to communicate with database in labview which is reentrant?

I mean I am focused on speed my labview-databse communcation up.

0 Kudos
Message 5 of 9
(3,977 Views)

There are some issues with you description of your problem. 

First, both loops are timed with a 100ms wait. 

Second both loop can not be stopped in a correct way. There is no way you can close the connection to the database. 

Third, you close the connection 2 times? or is it not to the same database/connection? 

0 Kudos
Message 6 of 9
(3,958 Views)

@vasicekv wrote:

Thank you Jim, it really helps me!

Do you also know any other library to communicate with database in labview which is reentrant?

I mean I am focused on speed my labview-databse communcation up.


Perhaps you should be considering why your consumer loop is so slow?  Is your database running on a dedicated server?  Is it getting bogged down?

 

Please share a little of your real code so we can try to improve the performance of your consumer loop.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 9
(3,929 Views)

Thanks for your replies,

My Consumer loop is in enclosed picture.

QUERY looks like comment at the bottom, but there are just and only just 1000 values to insert, but still it lasts 1 sec to insert 1000 values from labview to databse. I need to make it 50 times faster. What are my possibilities? Is there any much more better way?

Thanks in advance!

0 Kudos
Message 8 of 9
(3,908 Views)

I think I have a solution!

It is little weird to understand why labview works like that, but the result is ok.

There can´t be used Query VI inserting data from labview to database. I don´t think why, but this connection looks really limited. So i create a text file and use Bulk insert query, so then there is no data exchange between labview and database, but only between text file and database and that works fine.

Thanks all for helping me, I appreciate it!

0 Kudos
Message 9 of 9
(3,882 Views)