doc:todo:mysqlnd_vs_libmysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:todo:mysqlnd_vs_libmysql [2009/10/16 14:32] – documenting mysqlnd.net_cmd_buffer_size uwdoc:todo:mysqlnd_vs_libmysql [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 11: Line 11:
 mysqlnd is part of the PHP source code as of PHP 5.3. Therefore users do not need to install any MySQL libraries on their PHP build host. mysqlnd is part of the PHP source code as of PHP 5.3. Therefore users do not need to install any MySQL libraries on their PHP build host.
  
 +Windows builds downloaded from php.net use mysqlnd as their default MySQL client library as of PHP 5.3. With PHP 5.4 the default library used with mysql, mysqli and PDO_MySQL is mysqlnd on all platforms. Using the MySQL Client Library (AKA libmysql) is still supported. There are no plans to remove libmysql support.
 +
 +
 +==== Major features added after PHP 5.3.0 ====
 +
 +  * Compression is supported since PHP 5.3.1. The MySQL compressed client/server protocol. See also, http://bugs.php.net/bug.php?id=47017
 +  * SSL is supported since PHP 5.3.3.  See also, http://bugs.php.net/bug.php?id=49234
 +  * Named pipe support available as of PHP 5.3.4
 +
 +==== Feature and extension dependencies ====
 +
 +Mysqlnd is tightly integrated into PHP. It is using PHP infrastructure, for example, PHP Streams. Some mysqlnd features depend on other PHP extensions:
 +
 +  * Compression: requires Zlib extension, http://www.php.net/manual/en/zlib.installation.php
 +  * SSL: requires OpenSSL extension, http://www.php.net/manual/en/openssl.installation.php
 +
 +
 +Please make sure that you are using a PHP build with Zlib and OpenSSL support when switching from libmysql to mysqlnd. This will ensure that mysqlnd offers the same functionality as libmysql does.
 ==== Major feature differences ==== ==== Major feature differences ====
  
 **mysqlnd does not support:** **mysqlnd does not support:**
  
-  * The MySQL compressed client/server protocol. The implementation is done to 90% by Andrey - we need to test it. See also, http://bugs.php.net/bug.php?id=47017 
-  * SSL . Although it is on the TODO list at MySQL there is no schedule for it yet. See also, http://bugs.php.net/bug.php?id=49234 
-  * mysqlnd uses PHP Streams for networking: 
-    * no named pipes on Windows 
   * mysqlnd will not read my.cnf server configuration files   * mysqlnd will not read my.cnf server configuration files
  
Line 25: Line 39:
   * asynchronous queries   * asynchronous queries
   * 100+ statistics   * 100+ statistics
 +  * security: mysqlnd can inspect LOAD LOCAL INFILE and check open_basedir setting, libmysql won't care about open_basedir. libmysql allows accessing files which other PHP functions cannot access, if open_basedir is set
  
 **in general** **in general**
Line 44: Line 59:
     * note - records everything from all extensions using mysqlnd     * note - records everything from all extensions using mysqlnd
     * note (general, not mysqlnd specific): flag "O" vs. "o" - flush after every [disk] write yes/no -> performance     * note (general, not mysqlnd specific): flag "O" vs. "o" - flush after every [disk] write yes/no -> performance
 +    * note - only available with a debug build of PHP
  
   * mysqlnd.net_read_timeout   * mysqlnd.net_read_timeout
 +    * type: integer
 +    * default: 31536000
 +    * changeable: PHP_INI_SYSTEM
 +    * changelog:      Available since 5.3.0
     * see http://bugs.php.net/bug.php?id=49511     * see http://bugs.php.net/bug.php?id=49511
  
Line 84: Line 104:
 (The default change may/should make it into 5.31 - lets wait and see what the release manager decides) (The default change may/should make it into 5.31 - lets wait and see what the release manager decides)
  
 +The value can also be set using mysqli_option(link, MYSQLI_OPT_NET_CMD_BUFFER_SIZE, size)
  
 +  * mysqlnd.net_read_buffer_size
 +    * internal type:  long
 +    * default:        "32768"
 +    * changelog:      Available since 5.3.0
 +
 +Maximum read chunk size in bytes when reading the body of a MySQL command packet. The MySQL client server protocol encapsulated all its commands in packets. The packets consist of a small header and a body with the actual payload. The size of the body is encoded in the header. mysqlnd reads the body in chunks of MIN(header.size, mysqlnd.net_read_buffer_size) bytes. If a packet body is larger than mysqlnd.net_read_buffer_size bytes, mysqlnd has to call read() multiple times. 
 +
 +The value can also be set using mysqli_optionS(link, MYSQLI_OPT_NET_READ_BUFFER_SIZE, size)
 +
 +... we have never done any proper performance testing around this. Larger values force PHP streams to allocate larger buffers and we have to doo less read calls. On the other hand might the transport protocol (TCP or Unix Sockets) in use work even better with smaller buffers... but it should also depend on your SQL queries: do you have queries that generate result sets larger than mysqlnd.net_read_buffer_size ... No idea for a recommendation but "run your own tests and don't be disappointed if it makes no big difference".
 +
 +  * mysqlnd.log_mask
 +    * internal type:  long
 +    * default:        "0"
 +    * changelog:      Available since 5.3.0
 +
 +No meaning for a standard PHP binary, see http://blog.ulf-wendel.de/?p=272 . 
 +Bug in PHP 5.3.0: the default of 0 has disabled the update of the mysqlnd statistics "no_index_used", "bad_index_used", "slow_query". As of PHP 5.3.1 - if the patch makes it into 5.3.1 - the log mask does no longer impact collecting statistics.
  
  
Line 97: Line 136:
   * MYSQLI_OPT_INT_AND_FLOAT_NATIVE    * MYSQLI_OPT_INT_AND_FLOAT_NATIVE 
     * see also mysqli_options()     * see also mysqli_options()
 +    * see also the second last example at http://blog.ulf-wendel.de/?p=198 - it can give you tiny memory savings
  
   * MYSQLI_REFRESH_BACKUP_LOG   * MYSQLI_REFRESH_BACKUP_LOG
   * MYSQLI_OPT_NET_CMD_BUFFER_SIZE   * MYSQLI_OPT_NET_CMD_BUFFER_SIZE
     * see also mysqli_options()     * see also mysqli_options()
 +    * see also php.ini settings
  
   * MYSQLI_OPT_NET_READ_BUFFER_SIZE   * MYSQLI_OPT_NET_READ_BUFFER_SIZE
     * see also mysqli_options()     * see also mysqli_options()
 +    * see also php.ini settings
  
   * MYSQLI_ASYNC   * MYSQLI_ASYNC
Line 207: Line 249:
     * reason: not needed, you can workaround using PHP Streams. Also, MySQL Client Library call can be abused by users to crash PHP     * reason: not needed, you can workaround using PHP Streams. Also, MySQL Client Library call can be abused by users to crash PHP
     * test: mysqli_class_mysqli_driver_interface.phpt     * test: mysqli_class_mysqli_driver_interface.phpt
 +
 +**different behaviour:**
 +
 +  * mysql_stmt->set_attr() - MYSQLI_CURSOR_TYPE_NO_CURSOR, MYSQLI_CURSOR_TYPE_READ_ONLY, MYSQLI_CURSOR_TYPE_FOR_UPDATE, MYSQLI_CURSOR_TYPE_SCROLLABLE
 +    * reason: some of those constants are not documented by MySQL, they worked only in temporary MySQL 5.0 versions which never became GA
 +    * test: ext/mysqli/tests/mysqli_stmt_attr_set.phpt
 +    * mysqlnd only accepts MYSQLI_CURSOR_TYPE_NO_CURSOR and MYSQLI_CURSOR_TYPE_READ_ONLY
 +    * libmysql may accept more/other ones, return value may even change among libmysql versions - I don't know - undocumented, undefined
 +    
 +  * mysql_stmt->set_attr() - detection of invalid attributes
 +    * reason: feature request to libmysql
 +    * test: ext/mysqli/tests/mysqli_stmt_attr_set.phpt
 +    * mysqlnd detects invalid attributes and returns false when trying to set, libmysql won't
  
 === Statistics === === Statistics ===
Line 217: Line 272:
  
   * http://blog.ulf-wendel.de/?p=271 - final(?), at least we have no more ideas for now   * http://blog.ulf-wendel.de/?p=271 - final(?), at least we have no more ideas for now
 +
 +  * affected_rows patch from Andrey
 +
 +  * not working before PHP 5.3.1: no_index_used, bad_index_used, slow_queries
  
 === Warnings === === Warnings ===
doc/todo/mysqlnd_vs_libmysql.1255703564.txt.gz · Last modified: 2017/09/22 13:28 (external edit)