WordPress.org

Ready to get started?Download WordPress

Forums

mysql or mysqli is best? (24 posts)

  1. reza19
    Member
    Posted 2 years ago #

    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?

  2. phpzag
    Member
    Posted 2 years ago #

    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 http://www.phpzag.com/mysql/

  3. reza19
    Member
    Posted 2 years ago #

    tnks phpzag but why wordpress used MysqlDrive ?

  4. button999
    Member
    Posted 2 years ago #

    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.

  5. Amit Pachauri
    Member
    Posted 2 years ago #

    Thanks All.

  6. Aaron
    Member
    Posted 2 years ago #

    Voting over? :)

    I'd go with MYSQL too.

  7. 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

    http://wordpress.org/about/requirements/

  8. Shyam Kumar 2012
    Member
    Posted 2 years ago #

    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.

  9. jacksonjohn123
    Member
    Posted 2 years ago #

    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.

  10. shanept
    Member
    Posted 1 year ago #

    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%.

  11. Abhishek Ghosh
    Member
    Posted 1 year ago #

    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) :

    http://limitless-scrubland-5524.herokuapp.com/

    Its a pain to add plugins or update it though.

  12. shanept
    Member
    Posted 1 year ago #

    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.

  13. Abhishek Ghosh
    Member
    Posted 1 year ago #

    I will test with MySQLi give the url here.

  14. swatkats
    Member
    Posted 1 year ago #

    I think MYSQLi Is fastest.

    @ Abhishek, have you tried it?

    [Signature removed per forum rules]

  15. shanept
    Member
    Posted 1 year ago #

    swatkats,

    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 :)

    Regards,
    Shane

  16. Abhishek Ghosh
    Member
    Posted 1 year ago #

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

    MySQLi : http://www.webpagetest.org/result/121008_57_5TB/1/details/

    MySQL : http://www.webpagetest.org/result/121008_BS_5W2/1/details/

    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 :

    http://www.webpagetest.org/result/121008_M2_71Z/1/details/

    MySQL with HyperDB with WP Super Cache and all tweaks :

    http://www.webpagetest.org/result/121008_GP_85X/1/details/

    ~1 second loading time.

  17. ALVAW3
    Member
    Posted 1 year ago #

    thanks for that data friend and very nice job on the last one! A+ :)

  18. Abhishek Ghosh
    Member
    Posted 1 year ago #

    You are welcome alvaw and thanks for the A+.

  19. XarranBs
    Member
    Posted 1 year ago #

    Doesn't matter how you called it, Mysql remains Mysql... If you know what I mean. :)
    There are however three extensions, that let php utilize the mysql features.
    Namely:
    1. mysql_* extension - which is the first, the worst, and official deprecated.
    2. mysqli_* extension - which means 'improved' version. kk
    3. And, mysql odbc - this is the best driver / extension, and I strongly encourage using it.
    If I'm not mistaken the latest wp only supports odbc version, so if it gets successfully installed on your system you should worry about nothing.

  20. shanept
    Member
    Posted 1 year ago #

    Xarran BS - You did not mention the PDO extension.

    http://jp2.php.net/manual/en/ref.pdo-mysql.php

    Personally for all my databasing I use the MySQLi database connection, because I am only developing with MySQL databases. However if there is a chance you may be using multiple different DBMS, the PDO extension is most likely the best bet for you.

  21. XarranBs
    Member
    Posted 1 year ago #

    PDO_ODBC is a driver that implements the PHP Data Objects (PDO) interface...

    So it's the same thing I guess? isn't it?

  22. shanept
    Member
    Posted 1 year ago #

    Well, I am not sure.

    I have not used the ODBC driver - I assume that allows you to connect to many different DBMS?

    There is a PDO_MYSQL, however I think the main difference is that it looks like PDO is specifically re-written for each DBMS - I will look into this soon and confirm this... And that PDO is object-oriented. Is the ODBC extension procedural or object-oriented?

  23. Abhishek Ghosh
    Member
    Posted 1 year ago #

    And that PDO is object-oriented. Is the ODBC extension procedural or object-oriented?

    PDO is object oriented, ODBC extension is procedural (As far I can recall).

    By the way, I found a good DBMS comparison table - http://troels.arvin.dk/db/rdbms/

  24. shayanan
    Member
    Posted 1 year ago #

    I will test with MySQL.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags