Skip site navigation (1) Skip section navigation (2)

Re: Apache + PHP + Postgres Interaction

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Max Zorloff <zorloff(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Apache + PHP + Postgres Interaction
Date: 2007-08-23 17:16:48
Message-ID: 46CDC100.10508@commandprompt.com (view raw or flat)
Thread:
Lists: pgsql-general
-----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 ;)

> 
> The second one is that the machine with this setup is dual core Xeon
> 2.8ghz. I've read somewhere about
> the switching context problem and bad postgres performance. What are the
> effects? What are the symptoms?

You likely do not have this problem if you are running anywhere near a
current PostgreSQL release but you can check it with vmstat.

> And what will be the performance gain if I change the machine to equal
> Athlon?

Depends on the work load.

Sincerely,

Joshua D. Drake


> 
> Thank you in advance.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 


- --

      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
PostgreSQL solutions since 1997  http://www.commandprompt.com/
			UNIQUE NOT NULL
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzcEAATb/zqfZUUQRAkkEAKCc00kZu6YSDp1RWjY9zZeQVEYeVACeIsOl
hzyHOnynNSNWOrBakMeVKpc=
=LL5i
-----END PGP SIGNATURE-----

In response to

Responses

pgsql-general by date

Next:From: Lincoln YeohDate: 2007-08-23 17:29:03
Subject: Re: Postgres, fsync and RAID controller with 100M of internal cache & dedicated battery
Previous:From: Erik JonesDate: 2007-08-23 17:14:43
Subject: Re: Argument type list

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group