From: Nick Barr <nicky@chuckie.co.uk>
To: postgres@countup.de
Cc: pgsql-performance@postgresql.org
Subject: Re: Persistent Connections
Date: Sun, 25 Jan 2004 11:28:28 +0000
Message-ID: <4013A85C.1010406@chuckie.co.uk> (raw)
In-Reply-To: <20040124173209.933905A8170@kserver17.erfurt12.de>
References: <20040124173209.933905A8170@kserver17.erfurt12.de>
Hi,
postgres@countup.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: nicky@chuckie.co.uk, postgres@countup.de
Subject: Re: Persistent Connections
In-Reply-To: <4013A85C.1010406@chuckie.co.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox