What is up with Pear DB speed?
| From: | Jeff Bearer | Date: | Tue, 01 Jul 2003 16:17:04 +0000 |
| Subject: | What is up with Pear DB speed? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-6364@lists.php.net to get a copy of this message | ||
I've been using PEAR DB for quite a while now and I was a big fan until
about an hour ago. I liked the object oriented programming, portability
wasn't my reason for using it. I never expected that it would be
significantly slower than the native mysql functions.
Today I'm benchmarking some new servers that I'm setting up. The results
report that using pear on on my test page is 13 times slower than the
native functions for mysql.
Here are my benchmark specs:
I'm using http_load to test the site, the parameters of the test are to
run 10 concurrent clients for 60 seconds and see how many pages are
returned. The database is on a separate server so there is no CPU
overhead from the database query. The result set of the query is 40
records.
When I run my sample code with pear it returns an average of 24 pages a
second. When I run the same query with native functions it serves 322
pages a second.
Am I doing something grossly wrong with Pear DB or is it just that much
slower? If this is a fact of life, how come I never seen anything
mentioning that Pear DB is that much slower? There should be a big red
flashing warning or something.
Here are the sample pages I'm testing.
<?php
# With PEAR
include_once 'DB.php';
include_once 'DB/mysql.php';
$db = new DB_mysql;
$dsn = "mysql://user@host/db";
$db->connect (DB::parseDSN($dsn,true));
$sql = "SELECT email FROM members";
$result = $db->query($sql);
while($row = $result->fetchrow(2)){
echo "$row[email]<BR>\n";
}
?>
---------------------------------------------------
<?php
# Native
mysql_connect("host","user","");
mysql_select_db("db");
$sql = "SELECT email FROM members";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
echo "$row[email]<BR>\n";
}
?>
--
Jeff Bearer, RHCE
Webmaster, PittsburghLIVE.com