Support » Developing with WordPress » mysql or mysqli is best?

  • i have a question ?
    Mysqli conection is very quick!
    but wpdb class use mysql!!!!
    i think if this class change and new class writen by mysqli is best.
    is it?

Viewing 15 replies - 1 through 15 (of 23 total)
  • Yes it is. Actually in relation to PHP programming language, MySQL is the old database driver, and MySQLi is the Improved driver. MySQLi takes advantage of the newer features of MySQL 5. can go through

    tnks phpzag but why wordpress used MysqlDrive ?

    Thanks for that insight. I assumed WP used MySQLi because of the $wpdb->prepare() statement, but as it seems it uses mysql_real_escape_string on all the parameters (among some other calls). Now I should reconsider some of my code designs.

    Thanks All.

    Voting over? 🙂

    I’d go with MYSQL too.

    Ben Lobaugh (blobaugh)


    Jetpack Engineer

    mysqli is probably going to be used going forward. The reason it has not been used traditionally is that older versions of MySQL were supported and therefore mysqli could not be used. As of WP 3.2, MySQL 5 is the minimum requirement, thus making mysqli the new acceptable choice

    By help of mysqli we can do batch statement query for say any transaction oriented situation.So that either all queries will be executed or none of them.

    There are major difference between the Mysql and Mysqli extensions.

    Unless you’re using MySQL < 4.1 or PHP 4 you should be using the mysqli extension, even if you’re using the procedural version of it. There is NO reason to be using the mysql extension, it is not receiving active development (only maintenance) releases and it can not utilize any of the new MySQL features since 4.1 (5.0, 5.1, and 5.5 have all been stable releases since), such as character sets, prepared statements, multiple statements, transactions, enhanced debugging, embedded server support etc.

    Mysqli is also the suggested extension to be used for all new development.

    The MySQLi driver is better than MySQL, on more modern versions of the MySQL database. The ‘i’ stands for improved, and it brings some performance advantages.

    MySQL API choosing

    For new projects it is suggested to use the MySQLi driver.
    I assume that WPDB still uses the old MySQL driver for compatability reasons, and as the above link states, the performance improvements are sometimes as low as 0.1%.

    I used postgresql for experimental setup with modified WordPress. It works fine. Otherwise MySQL probably works better for production site.

    You can check (there is no post, no cache plugin), notice the speed (copy paste the url) :

    Its a pain to add plugins or update it though.

    Abhishek Ghosh, do you have any WordPress sites on the same server running on a MySQL(i) database connection? It would be interesting to compare the two.

    I will test with MySQLi give the url here.

    I think MYSQLi Is fastest.

    @ Abhishek, have you tried it?

    [Signature removed per forum rules]


    MySQLi is definately not slower, however it is not guarranteed to be faster in all circumstances.

    Do not quote me on this as I can not quite remember, and can not find the source but speed improvements can be as low as 0.04 seconds.

    @abhishek, any luck? If we do not hear back within the next few days I will do it, and report my findings 🙂


    @swatkats : Painful result with MySQLi. All tested with Cloud Database from Rackspace.

    MySQLi :

    MySQL :

    Both were run with all default. Technically MySQLi should work better. Pathetically, many links to functions / pages within WordPress WP Admin panel (like Plugin browsing) returned errors after ‘thinking’ for few seconds.

    PostgreSQL worked the best almost out of the box.

    MySQL with HyperDB :

    MySQL with HyperDB with WP Super Cache and all tweaks :

    ~1 second loading time.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘mysql or mysqli is best?’ is closed to new replies.