Search Postgresql Archives

Re: Persistent Connections in Webserver Environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.  :) 

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux