View Full Version : mySQL Connections
02-13-2003, 04:28 AM
I have an include at the top of all my asp pages that creates the object for the mySQL database. My question is, if i were to place this code in the global.asa for the Session_OnStart sub, would it be more efficent? Like would I gain better performance out of my database server?
Are you using that db call on every single one of your pages? If you are, in entirity, it would be semi-fine (technically fine, but I wouldn't do it). If you are not even using it on one page out of your entire site (and this depends on how much traffic that one page gets) then your wasting the server's process...especially with the already slow ASP processing on most NT setups (unless you've got clustering and load-balancing going on, which in that case do whatever you want ;)).
The more salient question would be if you are closing that connection/object or leaving it open for the server to timeout, especially if you do execute it on every page/instance.
02-13-2003, 07:13 AM
I am closing the connection at the end of the page. And yes, the database is utilized on every page.
So as long as I close the connection on every page, its okay? I was wondering like is it less demanding (server wise) to keep the connection active and then on the Session_OnEnd close it? So that it isn't recreating the connection everytime you view the page?
Thank you Feyd for your excellent response. :)
02-13-2003, 08:42 AM
it's not efficient if you would make the connection object as a session variable even if ALL your pages connect to the database. If the user becomes idle, the connection is still active and will have to wait for the session timeout to expire in order for it to be inactive (not advisable all the more since connection should be close first before being destroyed). You can turn on the connection pooling to manage the connections. follow the links below:
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.