php-doc-en/reference/mysqlnd/config.xml
2010-10-07 15:13:23 +00:00

267 lines
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="mysqlnd.config" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.runtime;
&extension.runtime;
<para>
<table>
<title>MySQL Native Driver Configuration Options</title>
<tgroup cols="4">
<thead>
<row>
<entry>Name</entry>
<entry>Default</entry>
<entry>Changeable</entry>
<entry>Changelog</entry>
</row>
</thead>
<tbody>
<row>
<entry><link linkend="mysqlnd.collect_statistics">mysqlnd.collect_statistics</link></entry>
<entry>"1"</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry>Available since PHP 5.3.0.</entry>
</row>
<row>
<entry><link linkend="mysqlnd.collect_memory_statistics">mysqlnd.collect_memory_statistics</link></entry>
<entry>"0"</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry>Available since PHP 5.3.0.</entry>
</row>
<row>
<entry><link linkend="mysqlnd.debug">mysqlnd.debug</link></entry>
<entry>"0"</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry>Available since PHP 5.3.0.</entry>
</row>
<row>
<entry><link linkend="mysqlnd.net_read_timeout">mysqlnd.net_read_timeout</link></entry>
<entry>"31536000"</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry>Available since PHP 5.3.0.</entry>
</row>
<row>
<entry><link linkend="mysqlnd.net_cmd_buffer_size">mysqlnd.net_cmd_buffer_size</link></entry>
<entry>5.3.0 - "2048", 5.3.1 - "4096"</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry>Available since PHP 5.3.0.</entry>
</row>
<row>
<entry><link linkend="mysqlnd.net_read_buffer_size">mysqlnd.net_read_buffer_size</link></entry>
<entry>"32768"</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry>Available since PHP 5.3.0.</entry>
</row>
</tbody>
</tgroup>
</table>
&ini.php.constants;
</para>
&ini.descriptions.title;
<para>
<variablelist>
<varlistentry xml:id="mysqlnd.collect_statistics">
<term>
<parameter>mysqlnd.collect_statistics</parameter>
<type>boolean</type>
</term>
<listitem>
<para>
Enables the collection of various client statistics which can be
accessed through <function>mysqli_get_client_stats</function>,
<function>mysqli_get_connection_stats</function>,
<function>mysqli_get_cache_stats</function> and are shown in
<literal>mysqlnd</literal> section of the output of the
<function>phpinfo</function> function as well.
</para>
<para>
This configuration setting enables all
<link linkend="mysqlnd.stats">MySQL Native Driver
statistics</link> except those relating to memory management.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mysqlnd.collect_memory_statistics">
<term>
<parameter>mysqlnd.collect_memory_statistics</parameter>
<type>boolean</type>
</term>
<listitem>
<para>
Enable the collection of various memory statistics which can be
accessed through <function>mysqli_get_client_stats</function>,
<function>mysqli_get_connection_stats</function>,
<function>mysqli_get_cache_stats</function> and are shown in
<literal>mysqlnd</literal> section of the output of the
<function>phpinfo</function> function as well.
</para>
<para>
This configuration setting enables the memory management
statistics within the overall set of
<link linkend="mysqlnd.stats">MySQL Native Driver
statistics</link>.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mysqlnd.debug">
<term>
<parameter>mysqlnd.debug</parameter> <type>boolean</type>
</term>
<listitem>
<para>
Records everything from all extensions using
<literal>mysqlnd</literal>. Only available with a debug build of
PHP.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mysqlnd.net_read_timeout">
<term>
<parameter>mysqlnd.net_read_timeout</parameter>
<type>integer</type>
</term>
<listitem>
<para>
<literal>mysqlnd</literal> and the MySQL Client Library,
<literal>libmysql</literal> use different networking APIs.
<literal>mysqlnd</literal> uses PHP streams, whereas
<literal>libmysql</literal> uses its own wrapper around the
operating level network calls. PHP, by default, sets a read
timeout of 60s for streams. This is set via
<filename>php.ini</filename>,
<literal>default_socket_timeout</literal>. This default applies to
all streams that set no other timeout value.
<literal>mysqlnd</literal> does not set any other value and
therefore connections of long running queries can be disconnected
after <literal>default_socket_timeout</literal> seconds resulting
in an error message <quote>2006 - MySQL Server has gone
away</quote>. The MySQL Client Library sets a default timeout of
365 * 24 * 3600 seconds (1 year) and waits for other timeouts to
occur, such as TCP/IP timeouts. <literal>mysqlnd</literal> now
uses the same very long timeout. The value is configurable through
a new <filename>php.ini</filename> setting:
<literal>mysqlnd.net_read_timeout</literal>.
<literal>mysqlnd.net_read_timeout</literal> gets used by any
extension (<literal>ext/mysql</literal>,
<literal>ext/mysqli</literal>, <literal>PDO_MySQL</literal>) that
uses <literal>mysqlnd</literal>. <literal>mysqlnd</literal> tells
PHP Streams to use <literal>mysqlnd.net_read_timeout</literal>.
Please note that there may be subtle differences between
<literal>MYSQL_OPT_READ_TIMEOUT</literal> from the MySQL Client
Library and PHP Streams, for example
<literal>MYSQL_OPT_READ_TIMEOUT</literal> is documented to work
only for TCP/IP connections and, prior to MySQL 5.1.2, only for
Windows. PHP streams may not have this limitation. Please check
the streams documentation, if in doubt.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mysqlnd.net_cmd_buffer_size">
<term>
<parameter>mysqlnd.net_cmd_buffer_size</parameter>
<type>long</type>
</term>
<listitem>
<para>
<literal>mysqlnd</literal> allocates an internal command/network
buffer of <literal>mysqlnd.net_cmd_buffer_size</literal> (in
<filename>php.ini</filename>) bytes for every connection. If a
MySQL Client Server protocol command, for example,
<literal>COM_QUERY</literal> (<quote>normal</quote> query), does
not fit into the buffer, <literal>mysqlnd</literal> will grow the
buffer to the size required for sending the command. Whenever the
buffer gets extended for one connection,
<literal>command_buffer_too_small</literal> will be incremented by
one.
</para>
<para>
If <literal>mysqlnd</literal> has to grow the buffer beyond its
initial size of <literal>mysqlnd.net_cmd_buffer_size</literal>
bytes for almost every connection, you should consider increasing
the default size to avoid re-allocations.
</para>
<para>
The default buffer size is 2048 bytes in PHP 5.3.0. In later
versions the default is 4096 bytes. The default can changed either
through the <filename>php.ini</filename> setting
<literal>mysqlnd.net_cmd_buffer_size</literal> or using
<literal>mysqli_options(MYSQLI_OPT_NET_CMD_BUFFER_SIZE, int
size)</literal>.
</para>
<para>
It is recommended that the buffer size be set to no less than 4096
bytes because <literal>mysqlnd</literal> also uses it when reading
certain communication packet from MySQL. In PHP 5.3.0,
<literal>mysqlnd</literal> will not grow the buffer if MySQL sends
a packet that is larger than the current size of the buffer. As a
consequence, <literal>mysqlnd</literal> is unable to decode the
packet and the client application will get an error. There are
only two situations when the packet can be larger than the 2048
bytes default of <literal>mysqlnd.net_cmd_buffer_size</literal> in
PHP 5.3.0: the packet transports a very long error message, or the
packet holds column meta data from
<literal>COM_LIST_FIELD</literal>
(<literal>mysql_list_fields()</literal> and the meta data come
from a string column with a very long default value (>1900 bytes).
</para>
<para>
As of PHP 5.3.2 mysqlnd does not allow setting buffers smaller
than 4096 bytes.
</para>
<para>
The value can also be set using <literal>mysqli_option(link,
MYSQLI_OPT_NET_CMD_BUFFER_SIZE, size)</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mysqlnd.net_read_buffer_size">
<term>
<parameter>mysqlnd.net_read_buffer_size</parameter>
<type>long</type>
</term>
<listitem>
<para>
Maximum read chunk size in bytes when reading the body of a MySQL
command packet. The MySQL client server protocol encapsulates 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. <literal>mysqlnd</literal> reads the body in chunks of
<literal>MIN(header.size, mysqlnd.net_read_buffer_size)</literal>
bytes. If a packet body is larger than
<literal>mysqlnd.net_read_buffer_size</literal> bytes,
<literal>mysqlnd</literal> has to call <literal>read()</literal>
multiple times.
</para>
<para>
The value can also be set using <literal>mysqli_optionS(link,
MYSQLI_OPT_NET_READ_BUFFER_SIZE, size)</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->