Re: passing resource id's through functions - Mailing list pgsql-php

From Andrew McMillan
Subject Re: passing resource id's through functions
Date
Msg-id 1011056343.26926.29.camel@kant.mcmillan.net.nz
Whole thread Raw
In response to Re: passing resource id's through functions  (Chadwick Rolfs <cmr@shell.gis.net>)
List pgsql-php
On Tue, 2002-01-15 at 11:15, Chadwick Rolfs wrote:
> Yes, that's it.  Using the $GLOBALS array works just fine, and I don't
> have a bunch of pconnections cluttering up the process list, apache, or
> postgresql.  I don't think persistent connections are meant to be _faster_
> as much as they are meant for cutting down on redundant connections.
> Unfortunately, I'm getting a bunch of redundant connections when pconnect
> is used.  Since I don't administer the server, and the ones who do are too
> busy to experement, I'll have to deal with it.  I'd like to know if
> anyone else is having the same problem with pconnect:
>
> pg_pconnect is in ONE file referred to by all of my other files.  So there
> is only one connect string.  It can't change unless I edit the connection
> file between invocations (let's just say it's STATIC)
>
> when I go to pg_exec with the pg_pconnect resource, I get a seperate
> connection for each exec!  This is clearly not supposed to be the case
> acoording to http://www.php.net/manual/en/function.pg-pconnect.php
>
> setting apache to only accept a certain amount of links is a good work
> around, but what about everyone else?  Won't my connections just get
> kicked off if other pconnections take over?  when I look at the postgres
> processes, I should see _ONE_ persistent connection, not nine
>
> The max conncection set is 64, so that won't be a problem, except that
> each persistent connection takes a little bit of memory (2.5%), and enough
> of them will actually slow the sever down.
>
> Thanks for the great suggestion on using php's global namespace!

With persistent connections you will (eventually) end up with one
postgresql client process for each apache server process.  If you set
the max connection limit below the max client limit of apache you will
end up with a machine that doesn't spiral out of control, but above that
limit your database driven content simply won't work.

Yes, the reason for using persistent connections definitely _is_
performance, but I don't think it is just connection time performance.
Longer running connections will have an element of caching which will
give further speed advantages.

Cheers,
                    Andrew.
--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
       Are you enrolled at http://schoolreunions.co.nz/ yet?


pgsql-php by date:

Previous
From: Andrew McMillan
Date:
Subject: Re: passing resource id's through functions
Next
From: Francisco Reyes
Date:
Subject: Long running queries and timeouts