On Aug 23, 2007, at 12:29 PM, Bill Moran wrote:
> In response to "Joshua D. Drake" <jd@commandprompt.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@myemma.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