Re: Apache + PHP + Postgres Interaction

From: Erik Jones <erik(at)myemma(dot)com>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Max Zorloff <zorloff(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Apache + PHP + Postgres Interaction
Date: 2007-08-23 17:48:37
Message-ID: EB399017-0DFD-4BD3-B31C-2D73C2FD6A93@myemma.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Aug 23, 2007, at 12:29 PM, Bill Moran wrote:

> In response to "Joshua D. Drake" <jd(at)commandprompt(dot)com>:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Max Zorloff wrote:
>>> Hello.
>>>
>>> I have a subject setup and a few questions.
>>>
>>> The first one is this. PHP establishes a connection to the Postgres
>>> database through pg_pconnect().
>>
>> Don't use pconnect. Use pgbouncer or pgpool.
>>
>>> Then it
>>> runs some query, then the script returns, leaving the persistent
>>> connection hanging. But the trouble
>>> is that in this case any query takes significantly more time to
>>> execute
>>> than in the case of one PHP script
>>> running the same query with different parameters for N times. How
>>> can I
>>> achieve the same performance in the first
>>> case? Persistent connections help but not enough - the queries
>>> are still
>>> 10 times slower than they would be on
>>> the 2nd time.
>>
>> Well you haven't given us any indication of data set or what you are
>> trying to do. However, I can tell you, don't use pconnect, its
>> broke ;)
>
> Broke? How do you figure?
>
> I'm not trying to argue the advantages of a connection pooler such as
> pgpool, but, in my tests, pconnect() does exactly what it's supposed
> to do: reuse existing connections. In our tests, we saw a 2x speed
> improvement over connect(). Again, I understand that pgpool will do
> even better ...

We were just talking about this less than two weeks ago: http://
archives.postgresql.org/pgsql-general/2007-08/msg00660.php

Erik Jones

Software Developer | Emma®
erik(at)myemma(dot)com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lincoln Yeoh 2007-08-23 17:49:36 Re: Adapter update.
Previous Message Richard Huxton 2007-08-23 17:48:20 Re: Adapter update.