persistent database connection

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
slowdash
Posts: 24
Joined: Wed Feb 22, 2012 10:52 am

persistent database connection

Post by slowdash » Tue Mar 06, 2012 9:23 am

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: persistent database connection

Post by bangkok » Tue Mar 06, 2012 10:04 am

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.

slowdash
Posts: 24
Joined: Wed Feb 22, 2012 10:52 am

Re: persistent database connection

Post by slowdash » Tue Mar 06, 2012 10:35 am

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: persistent database connection

Post by bangkok » Tue Mar 06, 2012 11:19 am

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).

Post Reply