X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6EE303AC1CE for ; Wed, 29 Dec 2004 18:15:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88561-02 for ; Wed, 29 Dec 2004 18:15:16 +0000 (GMT) Received: from tomts20-srv.bellnexxia.net (tomts20.bellnexxia.net [209.226.175.74]) by svr1.postgresql.org (Postfix) with ESMTP id 848BF3AC1B5 for ; Wed, 29 Dec 2004 18:15:01 +0000 (GMT) Received: from acer.sympatico.ca ([65.95.133.206]) by tomts20-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20041229181459.PFLT2034.tomts20-srv.bellnexxia.net@acer.sympatico.ca> for ; Wed, 29 Dec 2004 13:14:59 -0500 Message-Id: <5.2.1.1.0.20041229125718.00a02520@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Version 5.2.1 Date: Wed, 29 Dec 2004 13:13:39 -0500 To: pgsql-php@postgresql.org From: Frank Bax Subject: Re: too many clients In-Reply-To: References: <330532b604122908387f7ffde2@mail.gmail.com> <0DC9A380-59AB-11D9-B3B3-0003938BDF32@localnotion.com> <330532b604122908387f7ffde2@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/5 X-Sequence-Number: 2963 At 12:12 PM 12/29/04, Matthew Terenzio wrote: >On Dec 29, 2004, at 11:38 AM, Mitch Pirtle wrote: > >>You got a couple solutions, one of which is getting a connection >>pooler setup between apache(php) and postgres. SQL Relay >>(sqlrelay.sf.net) could be a common candidate, as I have used it in >>the past with great results. > >Yes, I have taken a look at that before. It might be a good time to try it. > >I don't exactly understand the technical difference between pooled >connections and persistent ones. > >pg_pconnect() is grabbing an existing open connection if one is available. > >How is a connection pool more efficient in doing something along these lines? Have you read the php docs on persistent connections? http://www.php.net/manual/en/features.persistent-connections.php pg_pconnect is sometimes used in situations where it does not make sense. As you mentioned, apache uses numerous child process. A persistent connection can only be reused if the following things are the same: - same apache child process requests the connection - same connect string (ie host, database, user are *all* the same) If you have a site where there are many databases and/or many users, it is very easy for apache to retain more persistent connections than your postgres limit. There are many variables when trying to figure out which function works better, so simply try it on your own system. If pg_connect does not add significant overhead, and manages to avoid the problems you mentioned, then use it instead of pg_pconnect. I haven't heard of pooled connections, but can only assume they somehow overcome the problems with pg_pconnect gets out of control - perhaps the connections are shared across apache child processes. Frank