Question

In the php.net site, they say that those who use mysql4.1 next to php5 or higher is required to use extremely "MYSQLI_" instead of "MYSQL_."

He wanted to know just one thing, it influences the performance of the site, several problems with site is down due to the database (this on any server).

Already using various solutions. For example, CACHE HTML pages.

But my doubt is really about on MYSQLI_ *, when we use it, she connects to the server and the specified DataBase. According to the php.net site is mysql mysqli improved and optimized mysql4.1 +.

I wonder if the traffic with a large MySQLi give better performance to the site.

PS.: I know the difference "mysqli" and "mysql", taking into consideration the PHP programming and structuring of MYSQL4.1+ (which has new types of columns). What I want to know is on multiple connections.

This question is about performance, thanks

Was it helpful?

Solution

You should read this:

http://blog.secaserver.com/2011/07/php-driver-mysql-mysqli-pdo-mysql/

mysqli provides better performance and increased functionality and as Evert said, it is especially noticeable if you use mysqlnd.

OTHER TIPS

A common comment here at StackOveflow whenever we see code using mysql_* functions should answer your question:

Please, don't use mysql_* functions for new code. They are no longer maintained and the community has begun the deprecation process. See the red box? Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide, this article will help to choose. If you care to learn, here is good PDO tutorial.

Yes, MySQLi could give better performance to your site. You can use persistent connections, which basically share the same idea of the well known connection pooling, but while the connection pooling is used in java development mostly(usually performed directly by the webserver, e.g. Apache-Tomcat), persistent connections are managed by MySQL and PHP.

Besides, MySQLi could help you to secure your queries, by adopting prepared statements.

Mysqli extension provides built-in cleanup handling code, which includes:

  • Rollback active transactions

  • Close prepared statements (always happens with PHP)

  • Close and drop temporary tables

  • Unlock tables

  • Reset session variables

  • Close handler

  • Release locks acquired with GET_LOCK()

All these features could help you to give better performance and security as well.

For more informations, you can refer to:

http://php.net/manual/en/mysqli.persistconns.php

The mysql_ functions are no longer maintained and deprecated. The mysqli_ functions will perform better, especially if you use the mysqlnd (native driver).

Stop using deprecated API's!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top