note 10472 modified in Persistent Database Connections by ronabop
| From: | ronabop@php.net | Date: | Sat, 13 Jan 2001 08:18:53 +0000 |
| Subject: | note 10472 modified in Persistent Database Connections by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9756@lists.php.net to get a copy of this message | ||
Test your potential speed increase! Here's a page I wrote:
<?
function microint()
{
$tmp = microtime();
$parts = explode(" ",$tmp);
$floattime = (float)$parts[0] + (float)$parts[1];
return $floattime;
}
$starttime = microint();
$connect = pg_pconnect("dbname=the_db user=the_user password=the_pw");
$endtime = microint();
$persistent = $endtime - $starttime;
$starttime = microint();
$connect = pg_connect("dbname=the_db user=the_user password=the_pw");
$endtime = microint();
$no_persistent = $endtime - $starttime;
echo "Without persistent connection, time was $no_persistent <br>";
echo "With persistent, time was $persistent <br>";
$percentage = $no_persistent / $persistent;
echo "This is $percentage times faster.";
?>
Don't let this be your only consideration, especially if both numbers are really small, but if
you're curious about the speed cost for non-persistent connections, this can help you out. Make
sure you refresh, too, because I found the times can vary.
http://www.php.net/manual/persistent-database-connections.php