I was unable to locate a satisfactory benchmark of PDO vs. ADOdb, so I decided create some to get an idea of the performance differences.
I expected PDO to beat ADOdb easily, since PDO is a native PHP library and requires no run-time include. See my Web App benchmarking methodology here to understand why I was unsatisfied with the existing PDO vs ADOdb and PEAR::NET library benchmarks I found online.
PDO vs ADOdb Benchmark - Select and Loop
MySQL SELECT Benchmark Results, 1000 Requests, APC Disabled
APC should give ADOdb an advantage, here are the results of the same benchmark with APC enabled. The performance times for the PDO benchmarks with APC enabled did not change significantly as there were only 3 lines of code for APC to cache.
MySQL SELECT Benchmark Results, 1000 Requests, APC Enabled
|Library||Concurrency||Total Time||Requests/Sec.||APC Speedup|
|ADOdb||1||1.65/sec||604.52||+1264% (vs no APC)|
|PDO||1||-||-||+225% (vs ADOdb)|
|ADOdb||50||1.25/sec||798.26||+795% (vs no APC)|
|PDO||50||-||-||+232% (vs ADOdb)|
|ADOdb||100||1.33/sec||751.72||+785% (vs no APC)|
|PDO||100||-||-||+249% (vs ADOdb)|
If performance is critical, don’t consider ADOdb unless an optimizer such as APC is installed. Even then, I do not recommend ADOdb unless ADOdb offers some critical feature that is missing in PDO. Even with APC installed the best run of ADOdb was 225% slower than with PDO.
Why? PDO is a native compiled library and not loaded at runtime.
What about PEAR::NET? I have never used this library so I didn’t go to the bother of including it in my benchmark. Also, the purpose of this benchmark was to demonstrate the speedup of using the native PHP library vs a large included library, and I feel that the PEAR library will perform in a similar fashion as the ADOdb library if it is anywhere near the same size and complexity. That is an assumption however…
I was questioned on my choice to exclude ADOdb with the ADOdb extension from this benchmark. I had given it little though at the start of this benchmark and decided to run the benchmark again to compare ADOdb with the extension installed to PDO’s best performance. I ran each benchmark here with and without APC enabled.
MySQL SELECT Benchmark Results, 1000 Requests, ADOdb Extension
|APC||Concurrency||Total Time||Requests/Sec.||Slowdown vs. PDO|
My conclusion regarding the ADOdb extension: Using my benchmarking methodology, there is little gain to be had with the extension enabled vs without it. I feel this is due to the fact that the ADOdb library must still be included at runtime even with the extension enabled in php.ini.
In my environment, to get within almost half of the speed of PDO, I need two PHP extensions enabled - APC and the ADOdb C extension. PDO remains my recommendation for a database abstraction library from a performance standpoint.
Another addition regarding my test environment: Intel Duo 2Ghz, 2GB RAM, Ubuntu 7.10, PHP 5.2.3 CGI, lighttpd 1.4.18. The disk is slow (5400rpm) so I suspect the slower IO is is increasing the library inclusion load time.