Hi,

[EMAIL PROTECTED] 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




---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
     joining column's datatypes do not match

Reply via email to