in reply to Re: Re: Search engine code critique
in thread Search engine code critique

Actually if you use this syntax you will pile up persistent connections under mod_perl. Trust me. We have done it. In production. Disconnecting is much more than good form.....

my $dbh = DBI->connect...

The connection is as you say persistent. This is immaterial. This will pile connections up running under mod_perl/vanilla/or off the command line. The my means that the handle to the connection disappears every time you re-exec your script (effectively a sub). The connection however remains.....

If you don't believe me put it in a loop and you will quickly bring your DB to its knees.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Re: Re: Search engine code critique
by bean (Monk) on Sep 19, 2003 at 19:47 UTC
    I can't argue with experience - your "does" beats my "should" (especially since I'm too lazy to check it myself). Sounds like a bug in Apache::DBI - it's supposed to keep track of instance/user/passwd (I think) combos and give you an existing connection if one matches/exists when you ask to connect. A copy of the connection handle is kept in Apache::DBI, so the "my" shouldn't make a difference - should it?
    Update
    Actually, it's more likely that something in your setup prevented Apache::DBI from being used by DBI - in which case the standard DBI::connect method would have been used, and without disconnects, connections would pile up.