Hudzilla.org - the homepage of Paul Hudson
Contents > Databases > PEAR::DB Wish List | Report Bug | About Me ]

9.6.4     Impeared performance?

This is NOT the latest copy of this book; click here for the latest version.

Bad puns aside, it is a legitimate concern if you are wondering at what cost the power of PEAR::DB comes. When you use direct database function calls, such as mysql_query(), there is no need to jump through hoops to figure out what database type is being referenced or the like, because the call is unambiguous. In PEAR::DB, a lot of extra work has to be done behind the scenes to make it work smoothly across the different DBMSs, and this has quite a heavy speed toll.

On average, you are likely to find PEAR::DB code will run at about 3/8 the speed of the equivalent DBMS-specific code (that is, just less than half the speed), although this will of course vary depending on the types of query you do. It is of course impossible for PEAR::DB to ever run as fast as native DBMS calls because PEAR::DB is written using PHP, and PHP scripts are much slower than compiled C programs.

However, you need to weigh the performance hit against the extra flexibility offered by PEAR::DB. PEAR::DB code can be transferred from MySQL to PostgreSQL to Microsoft SQL Server to Oracle, all simply by changing the initial DSN used to connect to the server. Furthermore, functionality such as prepared statements bring the database code closer to that of Microsoft's ADO technology, and should therefore help entice ASP and ASP.NET programmers over to PHP.





<< 9.6.3 Advanced PEAR::DB   9.7 SQLite >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is eight plus six?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow