note 16811 added to function.mysql-pconnect

From: Date: Wed, 14 Nov 2001 17:03:51 +0000
Subject: note 16811 added to function.mysql-pconnect
Groups: php.notes 
Request: Send a blank email to php-notes+get-20836@lists.php.net to get a copy of this message
I decided to try my own benchmarks to see what this is all about. I started with the script from <txtilde@hotmail.com> 15-Sep-2001 with this change: The formula for comparing the result times is bogus. A better one is this: ((($timetotal2 - $timetotal1)/$timetotal2)*100) and, I replaced the table name in the mysql_query() with a variable $table defined at the top, so it was easier to jump to different tables. I found that pconnect is *not* appreciably faster than connect - if the table has very little information in it, the % difference will be huge, but the actual access times are so small - so what. As the amount of data retrieved increases, the performance boost from pconnect decreases rapidly. I've included the numbers below. They speak for themselves. Make your own analysis - you might be surprised by the obvious result. Running: solaris 5.8 (x86) apache_1.3.20 mysql-3.23.41 php-4.0.6 ======================================= *** My results: *** First, on a real table, with ~2100 records I looked at the size in kbytes: ----------------------------------- # du -k table_0.MYD 312 table_0.MYD ----------------------------------- Executing 300 mysql_pconnect tests... pconnect time: 8.1228427886963 Executing 300 mysql_connect tests... connect time: 8.3556438684464 pconnect is 2.7861536874399% more effective Now, on a table with ~1500 records, ----------------------------------- # du -k table_1.MYD 25 table_1.MYD ----------------------------------- Executing 300 mysql_pconnect tests... pconnect time: 4.1799796819687 Executing 300 mysql_connect tests... connect time: 4.5096175670624 pconnect is 7.309663850463% more effective When I tried this on an empty table: ----------------------------------- # du -k table_2.MYD 0 table_2.MYD ----------------------------------- Executing 300 mysql_pconnect tests... pconnect time: 0.19236469268799 Executing 300 mysql_connect tests... connect time: 0.58351397514343 pconnect is 67.033404360075% more effective -- http://www.php.net/manual/en/function.mysql-pconnect.php http://master.php.net/manage/user-notes.php?action=edit+16811 http://master.php.net/manage/user-notes.php?action=delete+16811 http://master.php.net/manage/user-notes.php?action=reject+16811

« previous php.notes (#20836) next »