PHP Database APIs MySQL Edition
Thursday, May 31st, 2007So I decided to do a simple performance test after a friend linked me to this blog post of someone doing a comparison against a PostgreSQL database. I use MySQL at work so I wondered if there was much difference with the mysql drivers for these various APIs. The results actually seem to show PDO to be the winner when querying a MySQL database.
Here’s the results:
| Method | Time (ms) |
|---|---|
| PDO Prepared: | 0.01632 |
| PDO Query: | 0.01809 |
| MySQL Query: | 0.11709 |
| MySQLi: | 0.17366 |
| ADOdb: | 0.52558 |
| Zend_Db: | 0.74503 |
| PEAR::DB: | 1.21966 |
| MDB2: | 1.31814 |
This test was run on a Ubuntu PC, an AMD 1800+ (1.53Ghz) PHP 5.2.2 machine. A simple query was run 250 times returned about 270 rows, similar to the blog post I mentioned. The 250 query iterations were also run 10 times per API and the average of that is taken. The results fluctuate a little but are usually pretty close to the same. So it seems like for MySQL PDO does a pretty good job.
Edit: Added Zend_Db results, which uses PDO behind the scenes
Technorati Tags: database, mysql, performance, php, programming