php-doc-en/reference/mysqlnd/stats.xml

535 lines
14 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: $ -->
<chapter xml:id="mysqlnd.stats" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Statistics</title>
<para>
<emphasis role="bold">Using Statistical Data</emphasis>
</para>
<para>
MySQL Native Driver contains support for gathering statistics on the
communication between the client and the server. The statistics
gathered are of three main types:
</para>
<itemizedlist>
<listitem>
<para>
Client statistics
</para>
</listitem>
<listitem>
<para>
Connection statistics
</para>
</listitem>
<listitem>
<para>
Zval cache statistics
</para>
</listitem>
</itemizedlist>
<para>
If you are using the <literal>mysqli</literal> extension, these
statistics can be obtained through three API calls:
</para>
<itemizedlist>
<listitem>
<para>
<function>mysqli_get_client_stats</function>
</para>
</listitem>
<listitem>
<para>
<function>mysqli_get_connection_stats</function>
</para>
</listitem>
<listitem>
<para>
<function>mysqli_get_cache_stats</function>
</para>
</listitem>
</itemizedlist>
<note>
<para>
Statistics are aggregated among all extensions that use MySQL
Native Driver. For example, when compiling both
<literal>ext/mysql</literal> and <literal>ext/mysqli</literal>
against MySQL Native Driver, both function calls of
<literal>ext/mysql</literal> and <literal>ext/mysqli</literal>
will change the statistics. There is no way to find
out how much a certain API call of any extension that has been
compiled against MySQL Native Driver has impacted a certain
statistic. You can configure the PDO MySQL Driver,
<literal>ext/mysql</literal> and <literal>ext/mysqli</literal> to
optionally use the MySQL Native Driver. When doing so, all three
extensions will change the statistics.
</para>
</note>
<para>
<emphasis role="bold">Accessing Client Statistics</emphasis>
</para>
<para>
To access client statistics, you need to call
<function>mysqli_get_client_stats</function>. The function call does
not require any parameters.
</para>
<para>
The function returns an associative array that contains the name of
the statistic as the key and the statistical data as the value.
</para>
<para>
Client statistics can also be accessed by calling the
<function>phpinfo</function> function.
</para>
<para>
<emphasis role="bold">Accessing Connection Statistics</emphasis>
</para>
<para>
To access connection statistics call
<function>mysqli_get_connection_stats</function>. This takes the
database connection handle as the parameter.
</para>
<para>
The function returns an associative array that contains the name of
the statistic as the key and the statistical data as the value.
</para>
<para>
<emphasis role="bold">Accessing Zval Cache Statistics</emphasis>
</para>
<para>
The MySQL Native Driver also collects statistics from its internal
Zval cache. These statistics can be accessed by calling
<function>mysqli_get_cache_stats</function>.
</para>
<para>
The Zval cache statistics obtained may lead to a tweaking of
<filename>php.ini</filename> settings related to the Zval cache,
resulting in better performance.
</para>
<para>
<emphasis role="bold">Statistics returned by MySQL Native
Driver</emphasis>
</para>
<para>
The following table shows a list of statistics returned by the
<function>mysqli_get_client_stats</function>,
<function>mysqli_get_connections_stats</function> and
<function>mysqli_get_cache_stats</function> functions.
</para>
<informaltable>
<tgroup cols="1">
<colspec colwidth="30*"/>
<tbody>
<row>
<entry><emphasis role="bold">Statistic</emphasis></entry>
</row>
<row>
<entry>bytes_sent</entry>
</row>
<row>
<entry>bytes_received</entry>
</row>
<row>
<entry>packets_sent</entry>
</row>
<row>
<entry>packets_received</entry>
</row>
<row>
<entry>protocol_overhead_in</entry>
</row>
<row>
<entry>protocol_overhead_out</entry>
</row>
<row>
<entry>bytes_received_ok_packet</entry>
</row>
<row>
<entry>bytes_received_eof_packet</entry>
</row>
<row>
<entry>bytes_received_rset_header_packet</entry>
</row>
<row>
<entry>bytes_received_rset_field_meta_packet</entry>
</row>
<row>
<entry>bytes_received_rset_row_packet</entry>
</row>
<row>
<entry>bytes_received_prepare_response_packet</entry>
</row>
<row>
<entry>bytes_received_change_user_packet</entry>
</row>
<row>
<entry>packets_sent_command</entry>
</row>
<row>
<entry>packets_received_ok</entry>
</row>
<row>
<entry>packets_received_eof</entry>
</row>
<row>
<entry>packets_received_rset_header</entry>
</row>
<row>
<entry>packets_received_rset_field_meta</entry>
</row>
<row>
<entry>packets_received_rset_row</entry>
</row>
<row>
<entry>packets_received_prepare_response</entry>
</row>
<row>
<entry>packets_received_change_user</entry>
</row>
<row>
<entry>result_set_queries</entry>
</row>
<row>
<entry>non_result_set_queries</entry>
</row>
<row>
<entry>no_index_used</entry>
</row>
<row>
<entry>bad_index_used</entry>
</row>
<row>
<entry>slow_queries</entry>
</row>
<row>
<entry>buffered_sets</entry>
</row>
<row>
<entry>unbuffered_sets</entry>
</row>
<row>
<entry>ps_buffered_sets</entry>
</row>
<row>
<entry>ps_unbuffered_sets</entry>
</row>
<row>
<entry>flushed_normal_sets</entry>
</row>
<row>
<entry>flushed_ps_sets</entry>
</row>
<row>
<entry>ps_prepared_never_executed</entry>
</row>
<row>
<entry>ps_prepared_once_executed</entry>
</row>
<row>
<entry>rows_fetched_from_server_normal</entry>
</row>
<row>
<entry>rows_fetched_from_server_ps</entry>
</row>
<row>
<entry>rows_buffered_from_client_normal</entry>
</row>
<row>
<entry>rows_buffered_from_client_ps</entry>
</row>
<row>
<entry>rows_fetched_from_client_normal_buffered</entry>
</row>
<row>
<entry>rows_fetched_from_client_normal_unbuffered</entry>
</row>
<row>
<entry>rows_fetched_from_client_ps_buffered</entry>
</row>
<row>
<entry>rows_fetched_from_client_ps_unbuffered</entry>
</row>
<row>
<entry>rows_fetched_from_client_ps_cursor</entry>
</row>
<row>
<entry>rows_skipped_normal</entry>
</row>
<row>
<entry>rows_skipped_ps</entry>
</row>
<row>
<entry>copy_on_write_saved</entry>
</row>
<row>
<entry>copy_on_write_performed</entry>
</row>
<row>
<entry>command_buffer_too_small</entry>
</row>
<row>
<entry>connect_success</entry>
</row>
<row>
<entry>connect_failure</entry>
</row>
<row>
<entry>connection_reused</entry>
</row>
<row>
<entry>reconnect</entry>
</row>
<row>
<entry>pconnect_success</entry>
</row>
<row>
<entry>active_connections</entry>
</row>
<row>
<entry>active_persistent_connections</entry>
</row>
<row>
<entry>explicit_close</entry>
</row>
<row>
<entry>implicit_close</entry>
</row>
<row>
<entry>disconnect_close</entry>
</row>
<row>
<entry>in_middle_of_command_close</entry>
</row>
<row>
<entry>explicit_free_result</entry>
</row>
<row>
<entry>implicit_free_result</entry>
</row>
<row>
<entry>explicit_stmt_close</entry>
</row>
<row>
<entry>implicit_stmt_close</entry>
</row>
<row>
<entry>mem_emalloc_count</entry>
</row>
<row>
<entry>mem_emalloc_ammount</entry>
</row>
<row>
<entry>mem_ecalloc_count</entry>
</row>
<row>
<entry>mem_ecalloc_ammount</entry>
</row>
<row>
<entry>mem_erealloc_count</entry>
</row>
<row>
<entry>mem_erealloc_ammount</entry>
</row>
<row>
<entry>mem_efree_count</entry>
</row>
<row>
<entry>mem_malloc_count</entry>
</row>
<row>
<entry>mem_malloc_ammount</entry>
</row>
<row>
<entry>mem_calloc_count</entry>
</row>
<row>
<entry>mem_calloc_ammount</entry>
</row>
<row>
<entry>mem_realloc_count</entry>
</row>
<row>
<entry>mem_realloc_ammount</entry>
</row>
<row>
<entry>mem_free_count</entry>
</row>
<row>
<entry>proto_text_fetched_null</entry>
</row>
<row>
<entry>proto_text_fetched_bit</entry>
</row>
<row>
<entry>proto_text_fetched_tinyint</entry>
</row>
<row>
<entry>proto_text_fetched_short</entry>
</row>
<row>
<entry>proto_text_fetched_int24</entry>
</row>
<row>
<entry>proto_text_fetched_int</entry>
</row>
<row>
<entry>proto_text_fetched_bigint</entry>
</row>
<row>
<entry>proto_text_fetched_decimal</entry>
</row>
<row>
<entry>proto_text_fetched_float</entry>
</row>
<row>
<entry>proto_text_fetched_double</entry>
</row>
<row>
<entry>proto_text_fetched_date</entry>
</row>
<row>
<entry>proto_text_fetched_year</entry>
</row>
<row>
<entry>proto_text_fetched_time</entry>
</row>
<row>
<entry>proto_text_fetched_datetime</entry>
</row>
<row>
<entry>proto_text_fetched_timestamp</entry>
</row>
<row>
<entry>proto_text_fetched_string</entry>
</row>
<row>
<entry>proto_text_fetched_blob</entry>
</row>
<row>
<entry>proto_text_fetched_enum</entry>
</row>
<row>
<entry>proto_text_fetched_set</entry>
</row>
<row>
<entry>proto_text_fetched_geometry</entry>
</row>
<row>
<entry>proto_text_fetched_other</entry>
</row>
<row>
<entry>proto_binary_fetched_null</entry>
</row>
<row>
<entry>proto_binary_fetched_bit</entry>
</row>
<row>
<entry>proto_binary_fetched_tinyint</entry>
</row>
<row>
<entry>proto_binary_fetched_short</entry>
</row>
<row>
<entry>proto_binary_fetched_int24</entry>
</row>
<row>
<entry>proto_binary_fetched_int</entry>
</row>
<row>
<entry>proto_binary_fetched_bigint</entry>
</row>
<row>
<entry>proto_binary_fetched_decimal</entry>
</row>
<row>
<entry>proto_binary_fetched_float</entry>
</row>
<row>
<entry>proto_binary_fetched_double</entry>
</row>
<row>
<entry>proto_binary_fetched_date</entry>
</row>
<row>
<entry>proto_binary_fetched_year</entry>
</row>
<row>
<entry>proto_binary_fetched_time</entry>
</row>
<row>
<entry>proto_binary_fetched_datetime</entry>
</row>
<row>
<entry>proto_binary_fetched_timestamp</entry>
</row>
<row>
<entry>proto_binary_fetched_string</entry>
</row>
<row>
<entry>proto_binary_fetched_blob</entry>
</row>
<row>
<entry>proto_binary_fetched_enum</entry>
</row>
<row>
<entry>proto_binary_fetched_set</entry>
</row>
<row>
<entry>proto_binary_fetched_geometry</entry>
</row>
<row>
<entry>proto_binary_fetched_other</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</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
-->