On Tue, Nov 13, 2001 at 09:18:04PM -0500, Perrin Harkins wrote:
> > One run of my script takes about 2 seconds. This includes a lot of
> > database-queries, calculations and so on.  about 0.3 seconds are used
> > just for one command: $query=new CGI;
> 
> That's really awfully slow.  Are you positive it's running under mod_perl?
> Have you considered using Apache::Request instead of CGI.pm?
> 

its definitely running under mod_perl. But imho the time it takes to
create a new cgi-object should not depend too much wheter its running
under mod_perl or not, cause the CGI-module is loaded before. (In fact
I load in httpd.conf using PerlModule-Directive)

> > This is not a problem of my persistent variables, cause this works
> > with many other objects like db-handles (cant use Apache::DBI cause
> > this keeps to many handles opened, so I need to cache and pool on my
> > own), filehandles etc.
> 
> Whoa, you can't use Apache::DBI but you can cache database handles yourself?
> That doesn't make any sense.  What are you doing in your caching that's
> different from what Apache::DBI does?

This makes very much sense. Apache::DBI does not limit the number of
persistent connections. It just keeps all the connections open per
apache-process. This will sum up to about 20 open
database-connections, each having one postgres-client running 'idle in
transaction' - and my old small serversystem is going weak.  So I cant
cache all connections, but only a limited number and so I cache on my
own :) Beside: it is done with a few lines of code, so it wasnt much
work either:

 if (exists($ptr->{global}->{dbhandles}->{_some_id_string}))
 {
    $dbh=$ptr->{global}->{dbhandles}->{_some_id_string};
    $dbh or err($ptr,19); # there must have been something wrong internally
    if (not $dbh->ping) {$connect=1;$r='reconnect'}  # we just reconnect ..
    $dbh and $dbh->rollback;   # this issue a new begin-transaction and avoid several 
problem with 'current_timestamp' that dedlivers the value
                                    # of the time at the beginning of the transaction, 
even if this is hours ago. see TROUBLEREPORT1
    $r= "stored" if $r eq '-';
  } else {$connect=1;}   
  if ($connect)
  {
    $dbh=DBI->connect(connectinformation)
    ....
  }

and on exit I just disconnect all handles but keeping a specified
amount.  I would prefer to handle this in a special pooling-module
like Apache::DBI is, but where one can specify a maximum number of
open connections and a timeout per connection (connection will be
terminated after it was not used a specified amount of time).  As soon
as I get IPC::Sharable to work I'll consider writing such a thingy.

best,
peter


-- 
mag. peter pilsl

phone: +43 676 3574035
fax  : +43 676 3546512
email: [EMAIL PROTECTED]
sms  : [EMAIL PROTECTED]

pgp-key available

Reply via email to