Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP PDO vs normal mysqli speed performance benchmark [closed]

i m working on a project about social networking website where speed optimization is very critical.

is PDO is FASTER ?

i am thinking to switch to PDO is it recommended for use PDO for such a site ?

like image 642
Bhavesh G Avatar asked Jun 21 '11 07:06

Bhavesh G


People also ask

Is PDO faster than MySQLi?

PDO also supports client side queries. This means that when it prepares a query, it does not have to communicate with the server. Since MySQLi uses native prepared statements, it will may actually be faster to use mysqli_real_escape_string instead of using prepared statements, while it is still a secure solution.

Is PDO slower than MySQLi?

PDO vs MySQLi vs MySQL Performance Benchmark Basically they show that for SELECT queries using prepared statements MySQLi runs a bit faster.

Should I use MySQLi or PDO?

Both MySQLi and PDO have their advantages: PDO will work on 12 different database systems, whereas MySQLi will only work with MySQL databases. So, if you have to switch your project to use another database, PDO makes the process easy. You only have to change the connection string and a few queries.

Is PDO more secure than MySQLi?

PDO is more secure than the first two options and it is also faster in comparison with MySQLi procedural and MySQLi object-oriented. PDO is a database access layer that provides a fast and consistent interface for accessing and managing databases in PHP applications.


2 Answers

I doubt using PDO or MySQLi will be bottleneck, though, if you ask for bechmarks, here they are (nothing serious, just couple of tests).

In general, using one or another is a matter of taste, and bottlenecks usually are somewhere else (e.g., queries, indexes, PHP code etc).

One thing you might consider is using some DB wrapper, i.e., class that uses either PDO or MySQLi, whichever you prefer. In your code, use this wrapper instead of using PDO or MySQLi directly. If you do this, you'll be able to switch between PDO, MySQLi or any other library by changing single class instead of changing all the code.

like image 85
binaryLV Avatar answered Sep 26 '22 14:09

binaryLV


I did a mini benchmark on this a while back. Conclusion. PDO and MySQLi are very similar but the features in PDO are worth using.

http://cznp.com/blog/2/apples-and-oranges-mysqli-and-pdo

like image 27
Ólafur Waage Avatar answered Sep 25 '22 14:09

Ólafur Waage