Need advice for MySQL connection to be more effective.

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1467 Views - Last Post: 26 February 2014 - 08:06 AM Rate Topic: -----

#16 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6335
  • View blog
  • Posts: 21,747
  • Joined: 05-May 12

Re: Need advice for MySQL connection to be more effective.

Posted 26 February 2014 - 06:56 AM

I find it interesting that back in the 80's and 90's with the client-server database model rage, the recommendations was for the clients (at the desktops) was to open the connection once and keep the connection open. I think part of the reason for this was network latency was bad so negotiating and opening the connection was slow. As I recall, there many tutorials and demos of class libraries that made it easier to keep track of the open session. When did the recommendation switch over to opening connections only for as long as needed?

As an aside, if the recommendation is in general to connect only for a long as needed does that mean that people will be connecting with SSH, run a single command, and then disconnect; and then connect again for the next command and then disconnect? Does that web browsers should close their TCP connections to web servers instead of keeping them open in anticipation of the next user request?
Was This Post Helpful? 1
  • +
  • -

#17 jimzcoder   User is offline

  • D.I.C Regular

Reputation: 57
  • View blog
  • Posts: 351
  • Joined: 14-November 12

Re: Need advice for MySQL connection to be more effective.

Posted 26 February 2014 - 08:06 AM

@skydiver
i did a few readings before i came up with this logic of keeping only one connection for the rest of the commands, i don't think i'm of any position to oppose/agree or even answer on what you've shared for i don't have the enough knowledge/experience on this stuff.
What i can only do for now is to Thank You, for sharing your knowledge and insights on this one.

BTW
i followed what andrewsw shared and did some checking if the connection is up/down and do an appropriate action. This is what i came up with and seemed to fix the issue.

if (conn.State == ConnectionState.Closed || conn.State == ConnectionState.Broken)
            {
                OpenDB();
            }



this one seemed to fix the issue, as i haven't received reports from our staffs from different branches.

i'll keep you posted if something happened or if this one really fixed the problem.
Thanks so much for all your help.
More powers
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2