Re: passing resource id's through functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, 2002-01-12 at 04:44, Chadwick Rolfs wrote:
> I seem to have figured out that pg_connect returns a resource ID that will
> not pass into another function, and that pg_pconnect does.  I'm not too
> keen on the persistent connections.  Can someone confirm this belief?  I'm
> trying to remember where on php.net I read how to pass pg_connect
> resources to other functions, and haven't found it at functions,
> persistent connections, pg_connect or pg_pconnect.
> 
> Any help would be appreciated, and helpful :)

I run all my calls to pg_Exec inside a wrapper function which logs the
query to syslog if it fails for some reason, or if it takes unreasonably
long to execute (this has been a great aid to debugging and performance
improvement).  This means that _every_ time I want to execute a query I
am passing the appropriate database connection into my wrapper function.

I don't see any difference here between using pg_connect vs. pg_pconnect
for connecting to the database, other than performance.  I have recently
started to migrate back from pg_pconnect to pg_connect because I can get
the same performance without the resource overhead now that I use
DBBalancer to provide connection pooling.

It might be that I don't see any difference because connecting to the
database(s) is something I do globally, rather than inside a function,
or through instantiating an object.

If you use persistent connections, Apache has a "MaxRequestsPerChild"
setting, after which the Apache client process will exit, closing any
PHP persistent PostgreSQL connections as well.  The trouble is, that
setting this to an arbitrarily low number will reduce the benefit from
persistent connections in the first place, setting it arbitrarily high
can cause a problem if your application tickles any memory leaks in
Apache or PHP.

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?



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux