Re: Persistent Connections

From: Nick Barr <nicky(at)chuckie(dot)co(dot)uk>
To: postgres(at)countup(dot)de
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Persistent Connections
Date: 2004-01-25 11:28:28
Message-ID: 4013A85C.1010406@chuckie.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

postgres(at)countup(dot)de wrote:

> Hi
>
> I have a php script and i make a pg_pconnect
> If i want to make 4-10 pg_query in that script
> Have i to close the connection at end of the script?
> (i would say yes, is it right?)

If you want to make multiple pg_query's in a page you can, and you can
use the same connection. You dont have to use persistent connections for
this. Just open the connection and fire off the different queries. The
persistent connection remains open between different pages loading,
which is supposedly faster because you dont have the overhead of opening
the connection.

If you want to use a persistent connection then definitely dont close it
at the bottom of the page. If you want to use the other connection
(pg_connect, non-persistent) then you dont have to close this connection
at the bottom of the page because PHP does it for you, although you can
if you are feeling nice ;-).

>
> Sorry I m a little bit confused about the persistent thing!!
> Is it smart to use persistent connections at all if i expect 100K
> Users to hit the script in an hour and the script calls up to 10-15 pg
> functions?
> I have at the mom one function but the server needs 500 ms, its a
> little bit too much i think, and it crashed when i had 20K users
>

Use the persistent connection but make sure the parameters in
postgresql.conf match up with the Apache config. The specific settings
are MaxClients in httpd.conf and max_connections in postgresql.conf.
Make sure that max_connections is at least as big as MaxClients for
every database that your PHP scripts connect to.

> Thanks
> Bye

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Ivan Voras 2004-01-25 12:23:23 Re: Benchmarking PostgreSQL?
Previous Message Tom Lane 2004-01-25 02:55:50 Re: Benchmarking PostgreSQL?