PEAR DB speed up
| From: | Tomas V.V.Cox | Date: | Sun, 09 Dec 2001 21:56:55 +0000 |
| Subject: | PEAR DB speed up | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-3425@lists.php.net to get a copy of this message | ||
Hi,
I reviewed a great part of the actual PEAR DB code to make it more
faster and light. I'm quite happy with the results, according to the
John Lim benchmark suite (dbbench-2001-10-20.zip) the results in my box
were:
Native mysql 5.7205570936203
ADODB 9.3135859966278
PEAR DB 3a 10.585510969162
PEAR DB 2 15.077128052711
(I named my hack PEAR DB 3a and used fetchInto())
Internally the summary of changes were:
- Only use two files instead of three: DB.php and the driver (reduced
the I/O access and the size of code to parse).
- The result object is now declared in each driver instead of having
the DB_result object.
- Now the query() method is done directly by the driver no longer
need the DB_common interface to Driver::simpleQuery().
- The DB_error class is no longer needed and the error handling
mechanism is done by DB_common::raiseError.
- Dropped unused and unsupported old code.
- Fixed a lot of PHPDoc comments.
- Preserved almost all the functionality/compability (only minor
things hasn't being yet integrated, like DB_FETCHMODE_OBJECT).
- Adapted all the tests to work with this changes (for ex the
simpleQuery
test and things like so).
Why is PEAR DB still a little bit slower than ADODB?
Mainly because:
- PEAR DB sets the type of fetch in the fetch method so we need to
do some more repeated comparisons.
- PEAR DB checks for errors when the native fetch function fails.
- PEAR DB has the logic for the non-sequencial fetching inside the
fetch method.
Status
For the moment only the mysql driver has been changed and updated (it
isn't too much work to do the properly changes for the others).
Code
I uploaded what is done to:
http://vulcanonet.com/soft/PEAR_DB-3.tgz
Comments on areas that can be improved or the chance of officially
adopting that are welcome.
Tomas V.V.Cox