Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts

    mySQL Connections

    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?
    OracleGuy

  • #2
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    403
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.
    OracleGuy

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,050
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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:

    http://www.15seconds.com/issue/970531.htm
    http://www.4guysfromrolla.com/webtech/110598-1.shtml


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •