Reply
Where to store Database Connection
Old 04-07-2004, 10:26 PM Where to store Database Connection
D.Viddy's Avatar
Average Talker

Posts: 24
Location: Soldotna, Alaska
I've been reading an ASP 3.0 book and I was wondering if anyone had any input on the best place to store a database connection (to minimize server load). Would an application variable be the best place to store this connection? I want multiple users to be able to access one connection. Also I don't see how I could also store the recordset object to allow mulitple users to access one object. I guess I could put it in a session variable, but I think that would be very bad for the server. But putting the recordset into a session variable wouldn't be any different than putting it in a normal variable right? My web application relies heavily on the database to fill out all the pages. So if I was to store one recordset object in a session variable that would actually be better then making the server open and close a recordset multiple times for each page they visit? I'm I correct in this thinking?
__________________
-Dylan Vester
D.Viddy is offline
Reply With Quote
View Public Profile Visit D.Viddy's homepage!
 
When You Register, These Ads Go Away!
     
Old 04-09-2004, 10:05 AM
Experienced Talker

Posts: 31
Location: Worchester, MA
I don't understand what you mean by allowing multiple users to access one connection. A connection is just that - a connection, not a result set. If you were to have EVERYONE using the same connection, your performance would be very, very poor. This again is the case with your recordset. Why would you even want all of your users to share the same recordset object? Your performance would suffer greatly.

As to your question about the difference between server load on a session variable vs. a normal variable. A session variable does not go out of scope until the session expires - if I remember right the default session expiration time in IIS is 20 minutes AFTER the last request from a user. On the other hand, a "normal" variable goes out of scope as soon as the processing for the page is complete - often less than a second. So, for arguments sake, lets say that your recordset object uses 50k of memory. Stored in a session variable, that is 50k used FOR EACH VISITOR, for AT LEAST 20 minutes. Stored in a "normal" variable, that is 50k for a fraction of a second.

I cannot think of a "normal" situation where storing a recordset or connection object in a session or application variable is a good idea. In fact, many web hosts do not allow this activity as it places too heavy of a load on the server. Many sites have dynamic content generated from a database, and an effective approach is to create your connection, create a recordset, loop throug the results, then - optimally - close the connection. Even if the connection isn't explicitly closed via script, it will automatically be closed when the page is complted processing - however this is considered poor practice.



Quote:
Originally Posted by D.Viddy
I've been reading an ASP 3.0 book and I was wondering if anyone had any input on the best place to store a database connection (to minimize server load). Would an application variable be the best place to store this connection? I want multiple users to be able to access one connection. Also I don't see how I could also store the recordset object to allow mulitple users to access one object. I guess I could put it in a session variable, but I think that would be very bad for the server. But putting the recordset into a session variable wouldn't be any different than putting it in a normal variable right? My web application relies heavily on the database to fill out all the pages. So if I was to store one recordset object in a session variable that would actually be better then making the server open and close a recordset multiple times for each page they visit? I'm I correct in this thinking?
__________________
Powerful Email Marketing Tools
JoeGoldberg is offline
Reply With Quote
View Public Profile Visit JoeGoldberg's homepage!
 
Old 04-17-2004, 05:43 PM
Novice Talker

Posts: 7
Never store anything that you are not sure how big it can get in an application variable or session variable.

There is no such thing as storing a DB connection. You either use DSN or you don't. The DB connection can handle as many users as it can hold. If I remember correctly, Access 97 has a 10 user limit, Access 2000 has a 255 user limit and SQLserver can serve 32,767 per instance. Keep in mind though, the stability of your database has alot to do with how well you normalize the relationships.
cookiemonster is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Where to store Database Connection
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12474 seconds with 13 queries