note 10472 added to Persistent Database Connections

From: Date: Fri, 05 Jan 2001 16:54:07 +0000
Subject: note 10472 added to Persistent Database Connections
Groups: php.notes 
Request: Send a blank email to php-notes+get-9409@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/features.persistent-connections.php

« previous php.notes (#9409) next »