tags:

views:

6809

answers:

6

I'd like to know if anyone has any first-hand experience with this dichotomy. A few blogs say the mysql extension is faster than mysqli. Is this true?

And I'm only asking about speed. I know mysqli has features that are not present in the older extension.

A: 

http://www.google.com/search?q=mysqli+benchmark - first result looks to be what you're looking for, as do others on the first page.

ceejayoz
As the first result in google now seems to be <http://www.mysqlperformanceblog.com/?s=php+pdo+mysqli+benchmark>, I don't think that was quite what you meant. Perhaps in the future, you'd refrain from sardonic responses. Especially if this very page rises from being the sixth result under your google search.
Joseph Holsten
The point stands - the poster could have Googled and clicked the first result at the time and gotten the answer. That you now need to drop down to the second search result isn't particularly relevant.
ceejayoz
A: 

According to all the Google results for benchmarks linked by ceejayoz it looks like MySQL is at least slightly faster than MySQLi in all the benchmark tests. I do recommend reading the results for details but just figured I'd post something that directly answered the question and bumps up ceejayoz's answer.

Jay
+15  A: 

The MySQL extension is very slightly faster than MySQLi in most benchmarks I've seen reported. The difference is so slight, however, that this should probably not be your criterion for deciding between the two.

Other factors dwarf the difference in performance between mysql and mysqli. Using mod_php or FastCGI, a bytecode cache like APC, or using data caching judiciously to reduce database hits, are far more beneficial for overall performance of PHP scripts than the choice of MySQL extension.

Don't be penny wise and pound foolish! :-)

Bill Karwin
+1 just for the last line. Amma stealing that one!
MatW
What is the biggest difference between using mysql and mysqli then? I was taught to only use mysqli and i was never told why. Could you give me a brief explanation? Thanks
Drewdin
ext/mysqli supports more features of the underlying MySQL API, such as transactions and prepared queries with parameters. Also you can call mysqli functions in an object-oriented manner.
Bill Karwin
A: 

The PHP documentation has a good comparison of mysql, mysqli, and PDO. I know you only asked about speed, but others might find this useful. It talks about the feature differences between the options.

Don Kirkby
+2  A: 

"It depends."

For example, PHP MySQL vs MySQLi Database Access Metrics and the subsequent comments point out arguments both ways.

If you have a mature database and codebase, do some testing and see what works in your system. If not, stop worrying about premature optimization.

Alkini
+1  A: 

Unless milliseconds matter then don't worry. Surely if you have no need for the extra functionality provided by mysqli then just stick with the tried and tested mysql.

Taylor