You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Felipe de Jesús Molina Bravo <fj...@gmail.com> on 2010/04/21 18:33:19 UTC

best practie for open and close connection database

Hi

In my application, I opened my database from authentication handler and
close it from child exit handler. It is correct (is a best practice)? or is
a bad design?

where i can read for best practice for it?

thank's

Re: best practie for open and close connection database

Posted by Michael Peters <mp...@plusthree.com>.
On 04/21/2010 12:33 PM, Felipe de Jesús Molina Bravo wrote:

> In my application, I opened my database from authentication handler and
> close it from child exit handler. It is correct (is a best practice)? or
> is a bad design?

Typically it's best practice to not close DB handles. That's why 
Apache::DBI is such a popular module since it handles all of connection 
caching for you.

With some databases (I'm looking at you Oracle) it's expensive to create 
a new database connection so it's more important. With others (like 
MySQL) it's really cheap so there's not a big penalty for not caching.

There are some cases where caching connections is actually a bad thing: 
If you have too many application servers where each has a connection to 
your database and thus overwhelms your database with too many 
connections even though the actual load isn't overloading. But most 
people in this situation will use a proxy like DBD::Gofer to manage the 
DB connections.

-- 
Michael Peters
Plus Three, LP

Re: best practie for open and close connection database

Posted by Felipe de Jesús Molina Bravo <fj...@gmail.com>.
El 21 de abril de 2010 17:33, Chris Bennett
<ch...@bennettconstruction.biz>escribió:

> On 04/21/10 11:33, Felipe de Jesús Molina Bravo wrote:
>
>> Hi
>>
>> In my application, I opened my database from authentication handler and
>> close it from child exit handler. It is correct (is a best practice)? or
>> is a bad design?
>>
>> where i can read for best practice for it?
>>
>> thank's
>>
>>
>>
>>  Are you using Apache::DBI?
>

no ....

Is it a local database server or remote?


remote


> Are you almost always using the same database and user? Or mixed?
>

yes... I have a connection pool in database server (pgbouncer + pgsql 8.4 i)


thanks to all for your answares

Re: best practie for open and close connection database

Posted by Chris Bennett <ch...@bennettconstruction.biz>.
On 04/21/10 11:33, Felipe de Jesús Molina Bravo wrote:
> Hi
>
> In my application, I opened my database from authentication handler and
> close it from child exit handler. It is correct (is a best practice)? or
> is a bad design?
>
> where i can read for best practice for it?
>
> thank's
>
>
>
Are you using Apache::DBI?
Is it a local database server or remote?
Are you almost always using the same database and user? Or mixed?