Received: from pgn.com ([198.107.240.10]) by postgresql.org (8.11.3/8.11.4) with SMTP id g0EHRTV44551 for ; Mon, 14 Jan 2002 12:27:29 -0500 (EST) (envelope-from Culley_Harrelson@pgn.com) Received: from WIZ-Message_Server by pgn.com with Novell_GroupWise; Mon, 14 Jan 2002 09:27:21 -0800 Message-Id: X-Mailer: Novell GroupWise Internet Agent 5.5.4.1 Date: Mon, 14 Jan 2002 09:27:01 -0800 From: "Culley Harrelson" To: , Cc: Subject: Re: passing resource id's through functions Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=_EAB798E9.D0B1B4D8" X-Archive-Number: 200201/15 X-Sequence-Number: 822 This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=_EAB798E9.D0B1B4D8 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable DBBalancer looks interesting. Looks like you are part of the development t= eam with this project? What sort of performance difference to you see? Wh= en I made the decision to go with php/postgres as my primary development te= chnologies I never even started using persistant connections because of all= the mixed reviews. The database is local to the web server and performanc= e is fine. I would be interested in hearing more about this connection poo= ling though... culley >>> Andrew McMillan 01/11/02 08:02PM >>> 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. >=20 > 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. --=20 -------------------------------------------------------------------- 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? ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org --=_EAB798E9.D0B1B4D8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Description: HTML
DBBalancer looks interesting.  Looks like y= ou are=20 part of the development team with this project?  What sort of performa= nce=20 difference to you see?  When I made the decision to go with php/postgr= es as=20 my primary development technologies I never even started using persistant= =20 connections because of all the mixed reviews.  The database is local t= o the=20 web server and performance is fine.  I would be interested in hearing = more=20 about this connection pooling though...
 
culley

>>> Andrew McMillan <andrew@catalyst.net.nz&= gt;=20 01/11/02 08:02PM >>>
On Sat, 2002-01-12 at 04:44, Chadwick Rolf= s=20 wrote:
> I seem to have figured out that pg_connect returns a resourc= e ID=20 that will
> not pass into another function, and that pg_pconnect=20 does.  I'm not too
> keen on the persistent connections.  C= an=20 someone confirm this belief?  I'm
> trying to remember where on= =20 php.net I read how to pass pg_connect
> resources to other functions,= and=20 haven't found it at functions,
> persistent connections, pg_connect o= r=20 pg_pconnect.
>
> Any help would be appreciated, and helpful=20 :)

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

I don't see any difference here between using=20 pg_connect vs. pg_pconnect
for connecting to the database, other than=20 performance.  I have recently
started to migrate back from pg_pconn= ect=20 to pg_connect because I can get
the same performance without the resourc= e=20 overhead now that I use
DBBalancer to provide connection pooling.
It=20 might be that I don't see any difference because connecting to=20 the
database(s) is something I do globally, rather than inside a=20 function,
or through instantiating an object.

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

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


---------------------------(end of=20 broadcast)---------------------------
TIP 1: subscribe and unsubscribe= =20 commands go to majordomo@postgresql.org
--=_EAB798E9.D0B1B4D8--