chedder123
Programmer
I'm having a problem with the database connection using PostgreSQL.
Everytime I open a connection, am I supposed to close it in the Perl CGI script? For example:
$dbh = &dbh_connect();
$sql = "SELECT mediaid, folder, view_count FROM media ORDER BY folder;";
$sth = $dbh->prepare($sql) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
Is what I'm using to open the connection and collect the information. However, on my unix server processes it lists a HUGE portion being taken up by Postgres. For example:
root 27979 0.0 1.3 81308 3396 ? S 16:39 0:00 /usr/sbin/httpd -DHAVE_ACCESS -DHAVE_PROXY -DHAVE_AUTH_ANON -DHAVE_AC
apache 30719 0.0 1.4 81444 3776 ? S 16:47 0:01 /usr/sbin/httpd -DHAVE_ACCESS -DHAVE_PROXY -DHAVE_AUTH_ANON -DHAVE_AC
postgres 5205 1.4 1.1 8308 3020 ? S 17:12 0:00 postgres: apache media [local] UPDATE waiting
apache 5222 0.4 1.5 6228 3948 ? S 17:12 0:00 /usr/bin/perl /home/rgardner/html/admin/cycle.cgi
About 50 of those, which causes the database to reject more connections because it already has too many and slows the access time considerably. What would be causing the problem and how can I fix it? I tried using a
$dbh = &dbh_close();
at the end of the script to close it, but I actually have no idea if that works. Any help?
Thanks,
Chad Sanders
chad@successmm.com
Everytime I open a connection, am I supposed to close it in the Perl CGI script? For example:
$dbh = &dbh_connect();
$sql = "SELECT mediaid, folder, view_count FROM media ORDER BY folder;";
$sth = $dbh->prepare($sql) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
Is what I'm using to open the connection and collect the information. However, on my unix server processes it lists a HUGE portion being taken up by Postgres. For example:
root 27979 0.0 1.3 81308 3396 ? S 16:39 0:00 /usr/sbin/httpd -DHAVE_ACCESS -DHAVE_PROXY -DHAVE_AUTH_ANON -DHAVE_AC
apache 30719 0.0 1.4 81444 3776 ? S 16:47 0:01 /usr/sbin/httpd -DHAVE_ACCESS -DHAVE_PROXY -DHAVE_AUTH_ANON -DHAVE_AC
postgres 5205 1.4 1.1 8308 3020 ? S 17:12 0:00 postgres: apache media [local] UPDATE waiting
apache 5222 0.4 1.5 6228 3948 ? S 17:12 0:00 /usr/bin/perl /home/rgardner/html/admin/cycle.cgi
About 50 of those, which causes the database to reject more connections because it already has too many and slows the access time considerably. What would be causing the problem and how can I fix it? I tried using a
$dbh = &dbh_close();
at the end of the script to close it, but I actually have no idea if that works. Any help?
Thanks,
Chad Sanders
chad@successmm.com