Re: Persistent Connections in Webserver Environment - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Persistent Connections in Webserver Environment
Date
Msg-id 1115048486.13303.1445.camel@state.g2switchworks.com
Whole thread Raw
In response to Re: Persistent Connections in Webserver Environment  (Hannes Dorbath <light@theendofthetunnel.de>)
Responses Re: Persistent Connections in Webserver Environment
List pgsql-general
On Mon, 2005-05-02 at 10:32, Hannes Dorbath wrote:
> On 02.05.2005 16:41, Marco Colombo wrote:
>
> > Have you measured the real gain in using persistent connections at all?
>
> As simple as possible:
>
> <?php
> require_once('Benchmark/Timer.php');
> $timer =& new Benchmark_Timer();
> $timer->start();
>
> pg_pconnect('host=myhost dbname=database user=user');
> pg_query("SET search_path TO myschema;");
>
> $q = "SELECT u.login FROM users WHERE u.user_id = 1;";
>
> $qr = pg_query($q);
>
> print_r(pg_fetch_all($qr));
>
> $timer->setMarker('Database');
> $timer->stop();
> $timer->display();
> ?>
>
> Results:
>
> pconnect: 0.001435995101928
> connect:  0.016793966293335

But if the average PHP script takes 50 milliseconds to start up and 100
milliseconds to run, then either one is still pretty much noise.

Plus, neither benchmark is interesting really until you have pretty good
parallel load running.

It may well be that pconnect makes a difference under heavier load.  But
most the time, I've seen one or two queries that could be tuned make a
much larger difference than using pconnect.

And, if you haven't got apache / postgresql configured properly and run
out of connections, the connect time goes from 16 mS to hours as your
users wait for you to fix the connectivity issues.  :)

pgsql-general by date:

Previous
From: Hannes Dorbath
Date:
Subject: Re: Persistent Connections in Webserver Environment
Next
From: Hannes Dorbath
Date:
Subject: Re: Persistent Connections in Webserver Environment