From: | Bill Moran <wmoran(at)potentialtech(dot)com> |
---|---|
To: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
Cc: | Max Zorloff <zorloff(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Apache + PHP + Postgres Interaction |
Date: | 2007-08-23 17:29:46 |
Message-ID: | 20070823132946.54731950.wmoran@potentialtech.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 ...
Also, I'm curious as to whether he's timing the actual _query_ or the
entire script execution. If you're running a script multiple times
to get multiple queries, most of your time is going to be tied up in
PHP's parsing and startup -- unless I misunderstood the question.
--
Bill Moran
http://www.potentialtech.com
From | Date | Subject | |
---|---|---|---|
Next Message | Murali Maddali | 2007-08-23 17:30:10 | Re: Adapter update. |
Previous Message | Lincoln Yeoh | 2007-08-23 17:29:03 | Re: Postgres, fsync and RAID controller with 100M of internal cache & dedicated battery |