Page 1 of 1

persistent database connection

Posted: Tue Mar 06, 2012 9:23 am
by slowdash
is there an actual/profound performance impact with regards to a persistent database connection against explicitly opening and closing a database connection?

ex:

on openstack ->
open connection and set it to global
use that connection throughout

against

create a database connect/disconnect function

everytime you need to do something with a database do something like
-dbconnect
do your database routine here
-disconnect

thanks in advanced
-Rye

Re: persistent database connection

Posted: Tue Mar 06, 2012 10:04 am
by bangkok
I don't see any differences, at least from the users point of view.

I used to open the connexion once. But then, i believe it's a good practice to open/close within each script, because you can handle a network error for instance, instead of sending your SQL query in "the wild", and then waiting for a time out error.

Plus, if your user lets the application in a iddle state for a long time, then again you increase the risk of a network tiny error that would disable the connexion.

Re: persistent database connection

Posted: Tue Mar 06, 2012 10:35 am
by slowdash
thanks for the reply bangkok, appreciate it :)

would it make any difference with regards to database types, i mean would it use less memory/resource if say
you have a persistent database connection with a sqlite db against explicitly connection/disconnecting.

and does it make any difference if its in a mobile environment

thanks again

Re: persistent database connection

Posted: Tue Mar 06, 2012 11:19 am
by bangkok
I thought you were speaking for a network solution (a MySQL server for instance, and many client apps).

So in a sqllite, local db, desktop environnement i would say then it's really not important. You can keep the connexion open. As for mobile environnement, i don't have any experience (i've just started to play around with Android).