mysqlnd_ms_get_stats

(PECL mysqlnd_ms >= 1.0.0)

mysqlnd_ms_get_statsReturns query distribution and connection statistics

Description

array mysqlnd_ms_get_stats ( void )

Returns an array of statistics collected by the replication and load balancing plugin.

The PHP configuration setting mysqlnd_ms.collect_statistics controls the collection of statistics. The collection of statistics is disabled by default for performance reasons.

The scope of the statistics is the PHP process. Depending on your deployment model a PHP process may handle one or multiple requests.

Statistics are aggregated for all connections. It is not possible to tell how much queries originating from mysqli, PDO_MySQL or mysql API calls have contributed to the aggregated data values.

Parameters

This function has no parameters.

Return Values

Returns NULL if the PHP configuration directive mysqlnd_ms.enable has disabled the plugin. Otherwise, returns array of statistics.

Array of statistics

Statistic Description Version
use_slave Number of statements considered as read-only by the built-in query analyzer. Neither statements which begin with a SQL hint to force use of slave nor statements directed to a slave by an user-defined callback are included. The total number of statements sent to the slaves is use_slave + use_slave_sql_hint + use_slave_callback. Since 1.0.0.
use_master Number of statements not considered as read-only by the built-in query analyzer. Neither statements which begin with a SQL hint to force use of master nor statements directed to a master by an user-defined callback are included. The total number of statements sent to the master is use_master + use_master_sql_hint + use_master_callback. Since 1.0.0.
use_slave_sql_hint Number of statements sent to a slave because statement begins with the SQL hint to force use of slave. Since 1.0.0.
use_master_sql_hint Number of statements sent to a master because statement begins with the SQL hint to force use of master. Since 1.0.0.
use_last_used_sql_hint Number of statements sent to server which has run the previous statement, because statement begins with the SQL hint to force use of previously used server. Since 1.0.0.
use_slave_callback Number of statements sent to a slave because an user-defined callback has chosen a slave server for statement execution. Since 1.0.0.
use_master_callback Number of statements sent to a master because an user-defined callback has chosen a master server for statement execution. Since 1.0.0.
non_lazy_connections_slave_success Number of successfully opened slave connections from configurations not using lazy connections. The total number of successfully opened slave connections is non_lazy_connections_slave_success + lazy_connections_slave_success Since 1.0.0.
non_lazy_connections_slave_failed Number of failed slave connection attempts from configurations not using lazy connections. The total number of failed slave connection attempts is non_lazy_connections_slave_failed + lazy_connections_slave_failed Since 1.0.0.
non_lazy_connections_master_success Number of successfully opened master connections from configurations not using lazy connections. The total number of successfully opened master connections is non_lazy_connections_master_success + lazy_connections_master_success Since 1.0.0.
non_lazy_connections_master_failed Number of failed master connection attempts from configurations not using lazy connections. The total number of failed master connection attempts is non_lazy_connections_master_failed + lazy_connections_master_failed Since 1.0.0.
lazy_connections_slave_success Number of successfully opened slave connections from configurations using lazy connections. Since 1.0.0.
lazy_connections_slave_failed Number of failed slave connection attempts from configurations using lazy connections. Since 1.0.0.
lazy_connections_master_success Number of successfully opened master connections from configurations using lazy connections. Since 1.0.0.
lazy_connections_master_failed Number of failed master connection attempts from configurations using lazy connections. Since 1.0.0.
trx_autocommit_on Number of autocommit mode activations via API calls. This figure may be used to monitor activity related to the plugin configuration setting trx_stickiness. If, for example, you want to know if a certain API call invokes the mysqlnd library function trx_autocommit(), which is a requirement for trx_stickiness, you may call the user API function in question and check if the statistic has changed. The statistic is modified only by the plugins internal subclassed trx_autocommit() method. Since 1.0.0.
trx_autocommit_off Number of autocommit mode deactivations via API calls. Since 1.0.0.
trx_master_forced Number of statemens redirected to the master while trx_stickiness=master and autocommit mode is disabled. Since 1.0.0.

Examples

Example #1 mysqlnd_ms_get_stats() example

<?php
printf
("mysqlnd_ms.collect_statistics = %d\n"ini_get("mysqlnd_ms.collect_statistics"));
var_dump(mysqlnd_ms_get_stats());
?>

The above example will output:

mysqlnd_ms.collect_statistics = 0
array(13) {
  ["use_slave"]=>
  string(1) "0"
  ["use_master"]=>
  string(1) "0"
  ["use_slave_forced"]=>
  string(1) "0"
  ["use_master_forced"]=>
  string(1) "0"
  ["use_last_used_forced"]=>
  string(1) "0"
  ["non_lazy_connections_slave_success"]=>
  string(1) "0"
  ["non_lazy_connections_slave_failure"]=>
  string(1) "0"
  ["non_lazy_connections_master_success"]=>
  string(1) "0"
  ["non_lazy_connections_master_failure"]=>
  string(1) "0"
  ["lazy_connections_slave_success"]=>
  string(1) "0"
  ["lazy_connections_slave_failure"]=>
  string(1) "0"
  ["lazy_connections_master_success"]=>
  string(1) "0"
  ["lazy_connections_master_failure"]=>
  string(1) "0"
  ["trx_autocommit_on"]=>
  string(1) "0"
  ["trx_autocommit_off"]=>
  string(1) "0"
  ["trx_master_forced"]=>
  string(1) "0"
}

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top