Link to home
Start Free TrialLog in
Avatar of oliverp101698
oliverp101698

asked on

Persistent Database Connection - Good or Bad?

Hi there,

What are the disadvantages to having a persisent database connection in a VB application from the time the application is opened to the time it is closed? If the application performs a lot of database activity would the above scenario be preferrable to a lot of opening and closing? Thanks!


Oliver
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Generally speaking most people seem to agree that you should open the connection when you need it and
close it as soon as possible afterwards. The performance of the server is not significantly different
in both scenarios as the making/breaking the connection doesn't take much in the way of resources. What
you do of course reduce is the on-going IP traffic across the network and also the number of concurrent
connections to the server. This may be a general performance issue if you have a low-capacity network
and / or limited number of licences for the server.
Avatar of Brendt Hess
As a different view on this - it may depend on multiple factors.  How often you'll need to open/close the DB, how long each open/close takes, &c.

For example, let's assume your open method takes 10ms (1/100th of a second), and your close takes 5ms.

If you will be opening and closing the DB around once every 10 seconds, this will be a 0.15% overhead - generally insignificant.  If you open/close once a second on the average, then it's 1.5% - possibly noticable.  If 5 times a second, then it's 7.5% - probably unacceptable overhead.

Run a test to determine how long establishing and breaking your connection takes, and try to get a good estimate on how often the DB connection will be opened or closed.
ASKER CERTIFIED SOLUTION
Avatar of ianouii
ianouii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oliverp101698
oliverp101698

ASKER

Hey, thanks for all your comments everybody. How can I give you all some points and close this question?


Oliver
Hi oliverp,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days.  I will suggest to:

    Split points between: TimCottee and bhess1 and ianouii

oliverp, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will followup.

EXPERTS: Please post closing recommendations.
==========
DanRollins -- EE database cleanup volunteer
I'm ok with the points sharing. thanks.
Fine by me too Dan.
Share away...
Per recommendation, force-accepted.

Netminder
CS Moderator

TimCottee: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20322460
bhess1: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20322461