Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Dec 18, 2018 12:55 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Multi-User Queries with Single Database Connection
PostPosted: Mon Mar 11, 2013 6:08 pm 
Offline

Joined: Wed Oct 12, 2005 5:30 pm
Posts: 114
Location: Bryan, Texas
We've got a web app with multiple users, like 20-50 simultaneously. We have to lookup an id in a specific table on an MS SQL Server. It is a single lookup when the user logs in and then no connection is required to the database server. There are lots of other things happening when the user logs in and we are trying to cut down the time it takes. Rather than establishing a connection to the MS SQL Server every time a new user connects (within the session object), we would prefer to query the database server with an existing connection, wishfully a single web app connection on the App object. Since each session is actually a thread (right?), our assumption is that utilizing a single db connection could cause an issue, even if we are just reading and not writing. Is this correct? We read up on CriticalSection and this seems to be the solution. Does anybody have any insight on how to best implement it, if that is the solution to our problem? We assume it would need to be a property of the app class but what is the procedure to create an instance and use it with sessions?

Another related question.... We are building a dictionary when the web app loads as a property of the app class. If we look up values (never modifying) with sessions, is there any risk of problems with multiple sessions "reading" only the dictionary concurrently?


Top
 Profile  
Reply with quote  
 Post subject: Re: Multi-User Queries with Single Database Connection
PostPosted: Tue Mar 12, 2013 8:26 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:48 am
Posts: 3554
Location: Lenexa, KS
Just create a property for your database in the application object and reuse that everywhere. Open the connection in the App.Open event. Close it in the close event.

One word of caution. If you just have one connection you really can't do much in the way of transactions since that's PER connection. If that's no big deal then you're good to go.

Quote:
We are building a dictionary when the web app loads as a property of the app class. If we look up values (never modifying) with sessions, is there any risk of problems with multiple sessions "reading" only the dictionary concurrently?


As you stated earlier, Sessions are (cooperatively) threaded so there will never be a collision between threads accessing an object.

_________________
Bob K.

A blog about being a Real Studio/Xojo developer at http://www.bkeeneybriefs.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group