Documentation Home
MySQL 8.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.8Mb
PDF (A4) - 39.9Mb
Man Pages (TGZ) - 257.9Kb
Man Pages (Zip) - 364.9Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 8.4 Reference Manual  /  ...  /  NDB API Statistics Counters and Variables

25.6.16 NDB API 统计计数器和变量

NDB 对象执行或影响的各种统计计数器可用。这些操作包括启动和关闭(或中止)事务;主键和唯一键操作;表、范围和剪枝扫描;线程阻塞,等待各种操作完成;NDBCLUSTER 发送和接收数据和事件。计数器在 NDB 内核中被递增,每当 NDB API 调用被执行或数据被发送到或从数据节点时。 mysqld 将这些计数器暴露为系统状态变量;它们的值可以在 SHOW STATUS 的输出中读取,也可以通过查询性能_schema 中的 session_ statusglobal_status 表。通过比较在操作 NDB 表的语句之前和之后的值,您可以观察对应的 API 级别操作,并且了解执行语句的成本。

您可以使用以下SHOW STATUS语句列出所有这些状态变量:

mysql> SHOW STATUS LIKE 'ndb_api%';
+----------------------------------------------+-------------+
| Variable_name                                | Value       |
+----------------------------------------------+-------------+
| Ndb_api_wait_exec_complete_count             | 11          |
| Ndb_api_wait_scan_result_count               | 14          |
| Ndb_api_wait_meta_request_count              | 74          |
| Ndb_api_wait_nanos_count                     | 31453031678 |
| Ndb_api_bytes_sent_count                     | 3336        |
| Ndb_api_bytes_received_count                 | 103568      |
| Ndb_api_trans_start_count                    | 10          |
| Ndb_api_trans_commit_count                   | 2           |
| Ndb_api_trans_abort_count                    | 4           |
| Ndb_api_trans_close_count                    | 10          |
| Ndb_api_pk_op_count                          | 6           |
| Ndb_api_uk_op_count                          | 0           |
| Ndb_api_table_scan_count                     | 3           |
| Ndb_api_range_scan_count                     | 1           |
| Ndb_api_pruned_scan_count                    | 0           |
| Ndb_api_scan_batch_count                     | 3           |
| Ndb_api_read_row_count                       | 11          |
| Ndb_api_trans_local_read_row_count           | 9           |
| Ndb_api_adaptive_send_forced_count           | 5           |
| Ndb_api_adaptive_send_unforced_count         | 11          |
| Ndb_api_adaptive_send_deferred_count         | 0           |
| Ndb_api_event_data_count                     | 0           |
| Ndb_api_event_nondata_count                  | 0           |
| Ndb_api_event_bytes_count                    | 0           |
| Ndb_api_event_data_count_injector            | 0           |
| Ndb_api_event_nondata_count_injector         | 0           |
| Ndb_api_event_bytes_count_injector           | 0           |
| Ndb_api_wait_exec_complete_count_slave       | 0           |
| Ndb_api_wait_scan_result_count_slave         | 0           |
| Ndb_api_wait_meta_request_count_slave        | 0           |
| Ndb_api_wait_nanos_count_slave               | 0           |
| Ndb_api_bytes_sent_count_slave               | 0           |
| Ndb_api_bytes_received_count_slave           | 0           |
| Ndb_api_trans_start_count_slave              | 0           |
| Ndb_api_trans_commit_count_slave             | 0           |
| Ndb_api_trans_abort_count_slave              | 0           |
| Ndb_api_trans_close_count_slave              | 0           |
| Ndb_api_pk_op_count_slave                    | 0           |
| Ndb_api_uk_op_count_slave                    | 0           |
| Ndb_api_table_scan_count_slave               | 0           |
| Ndb_api_range_scan_count_slave               | 0           |
| Ndb_api_pruned_scan_count_slave              | 0           |
| Ndb_api_scan_batch_count_slave               | 0           |
| Ndb_api_read_row_count_slave                 | 0           |
| Ndb_api_trans_local_read_row_count_slave     | 0           |
| Ndb_api_adaptive_send_forced_count_slave     | 0           |
| Ndb_api_adaptive_send_unforced_count_slave   | 0           |
| Ndb_api_adaptive_send_deferred_count_slave   | 0           |
| Ndb_api_wait_exec_complete_count_replica     | 0           |
| Ndb_api_wait_scan_result_count_replica       | 0           |
| Ndb_api_wait_meta_request_count_replica      | 0           |
| Ndb_api_wait_nanos_count_replica             | 0           |
| Ndb_api_bytes_sent_count_replica             | 0           |
| Ndb_api_bytes_received_count_replica         | 0           |
| Ndb_api_trans_start_count_replica            | 0           |
| Ndb_api_trans_commit_count_replica           | 0           |
| Ndb_api_trans_abort_count_replica            | 0           |
| Ndb_api_trans_close_count_replica            | 0           |
| Ndb_api_pk_op_count_replica                  | 0           |
| Ndb_api_uk_op_count_replica                  | 0           |
| Ndb_api_table_scan_count_replica             | 0           |
| Ndb_api_range_scan_count_replica             | 0           |
| Ndb_api_pruned_scan_count_replica            | 0           |
| Ndb_api_scan_batch_count_replica             | 0           |
| Ndb_api_read_row_count_replica               | 0           |
| Ndb_api_trans_local_read_row_count_replica   | 0           |
| Ndb_api_adaptive_send_forced_count_replica   | 0           |
| Ndb_api_adaptive_send_unforced_count_replica | 0           |
| Ndb_api_adaptive_send_deferred_count_replica | 0           |
| Ndb_api_wait_exec_complete_count_session     | 0           |
| Ndb_api_wait_scan_result_count_session       | 3           |
| Ndb_api_wait_meta_request_count_session      | 6           |
| Ndb_api_wait_nanos_count_session             | 2022486     |
| Ndb_api_bytes_sent_count_session             | 268         |
| Ndb_api_bytes_received_count_session         | 10332       |
| Ndb_api_trans_start_count_session            | 1           |
| Ndb_api_trans_commit_count_session           | 0           |
| Ndb_api_trans_abort_count_session            | 0           |
| Ndb_api_trans_close_count_session            | 1           |
| Ndb_api_pk_op_count_session                  | 0           |
| Ndb_api_uk_op_count_session                  | 0           |
| Ndb_api_table_scan_count_session             | 1           |
| Ndb_api_range_scan_count_session             | 0           |
| Ndb_api_pruned_scan_count_session            | 0           |
| Ndb_api_scan_batch_count_session             | 2           |
| Ndb_api_read_row_count_session               | 2           |
| Ndb_api_trans_local_read_row_count_session   | 2           |
| Ndb_api_adaptive_send_forced_count_session   | 1           |
| Ndb_api_adaptive_send_unforced_count_session | 0           |
| Ndb_api_adaptive_send_deferred_count_session | 0           |
+----------------------------------------------+-------------+
90 rows in set (0.00 sec)

这些状态变量也可以从性能chema的session_statusglobal_status表中获取,如下所示:

mysql> SELECT * FROM performance_schema.session_status
    ->   WHERE VARIABLE_NAME LIKE 'ndb_api%';
+----------------------------------------------+----------------+
| VARIABLE_NAME                                | VARIABLE_VALUE |
+----------------------------------------------+----------------+
| Ndb_api_wait_exec_complete_count             | 11             |
| Ndb_api_wait_scan_result_count               | 14             |
| Ndb_api_wait_meta_request_count              | 81             |
| Ndb_api_wait_nanos_count                     | 119485762051   |
| Ndb_api_bytes_sent_count                     | 3476           |
| Ndb_api_bytes_received_count                 | 105372         |
| Ndb_api_trans_start_count                    | 10             |
| Ndb_api_trans_commit_count                   | 2              |
| Ndb_api_trans_abort_count                    | 4              |
| Ndb_api_trans_close_count                    | 10             |
| Ndb_api_pk_op_count                          | 6              |
| Ndb_api_uk_op_count                          | 0              |
| Ndb_api_table_scan_count                     | 3              |
| Ndb_api_range_scan_count                     | 1              |
| Ndb_api_pruned_scan_count                    | 0              |
| Ndb_api_scan_batch_count                     | 3              |
| Ndb_api_read_row_count                       | 11             |
| Ndb_api_trans_local_read_row_count           | 9              |
| Ndb_api_adaptive_send_forced_count           | 5              |
| Ndb_api_adaptive_send_unforced_count         | 11             |
| Ndb_api_adaptive_send_deferred_count         | 0              |
| Ndb_api_event_data_count                     | 0              |
| Ndb_api_event_nondata_count                  | 0              |
| Ndb_api_event_bytes_count                    | 0              |
| Ndb_api_event_data_count_injector            | 0              |
| Ndb_api_event_nondata_count_injector         | 0              |
| Ndb_api_event_bytes_count_injector           | 0              |
| Ndb_api_wait_exec_complete_count_slave       | 0              |
| Ndb_api_wait_scan_result_count_slave         | 0              |
| Ndb_api_wait_meta_request_count_slave        | 0              |
| Ndb_api_wait_nanos_count_slave               | 0              |
| Ndb_api_bytes_sent_count_slave               | 0              |
| Ndb_api_bytes_received_count_slave           | 0              |
| Ndb_api_trans_start_count_slave              | 0              |
| Ndb_api_trans_commit_count_slave             | 0              |
| Ndb_api_trans_abort_count_slave              | 0              |
| Ndb_api_trans_close_count_slave              | 0              |
| Ndb_api_pk_op_count_slave                    | 0              |
| Ndb_api_uk_op_count_slave                    | 0              |
| Ndb_api_table_scan_count_slave               | 0              |
| Ndb_api_range_scan_count_slave               | 0              |
| Ndb_api_pruned_scan_count_slave              | 0              |
| Ndb_api_scan_batch_count_slave               | 0              |
| Ndb_api_read_row_count_slave                 | 0              |
| Ndb_api_trans_local_read_row_count_slave     | 0              |
| Ndb_api_adaptive_send_forced_count_slave     | 0              |
| Ndb_api_adaptive_send_unforced_count_slave   | 0              |
| Ndb_api_adaptive_send_deferred_count_slave   | 0              |
| Ndb_api_wait_exec_complete_count_replica     | 0              |
| Ndb_api_wait_scan_result_count_replica       | 0              |
| Ndb_api_wait_meta_request_count_replica      | 0              |
| Ndb_api_wait_nanos_count_replica             | 0              |
| Ndb_api_bytes_sent_count_replica             | 0              |
| Ndb_api_bytes_received_count_replica         | 0              |
| Ndb_api_trans_start_count_replica            | 0              |
| Ndb_api_trans_commit_count_replica           | 0              |
| Ndb_api_trans_abort_count_replica            | 0              |
| Ndb_api_trans_close_count_replica            | 0              |
| Ndb_api_pk_op_count_replica                  | 0              |
| Ndb_api_uk_op_count_replica                  | 0              |
| Ndb_api_table_scan_count_replica             | 0              |
| Ndb_api_range_scan_count_replica             | 0              |
| Ndb_api_pruned_scan_count_replica            | 0              |
| Ndb_api_scan_batch_count_replica             | 0              |
| Ndb_api_read_row_count_replica               | 0              |
| Ndb_api_trans_local_read_row_count_replica   | 0              |
| Ndb_api_adaptive_send_forced_count_replica   | 0              |
| Ndb_api_adaptive_send_unforced_count_replica | 0              |
| Ndb_api_adaptive_send_deferred_count_replica | 0              |
| Ndb_api_wait_exec_complete_count_session     | 0              |
| Ndb_api_wait_scan_result_count_session       | 3              |
| Ndb_api_wait_meta_request_count_session      | 6              |
| Ndb_api_wait_nanos_count_session             | 2022486        |
| Ndb_api_bytes_sent_count_session             | 268            |
| Ndb_api_bytes_received_count_session         | 10332          |
| Ndb_api_trans_start_count_session            | 1              |
| Ndb_api_trans_commit_count_session           | 0              |
| Ndb_api_trans_abort_count_session            | 0              |
| Ndb_api_trans_close_count_session            | 1              |
| Ndb_api_pk_op_count_session                  | 0              |
| Ndb_api_uk_op_count_session                  | 0              |
| Ndb_api_table_scan_count_session             | 1              |
| Ndb_api_range_scan_count_session             | 0              |
| Ndb_api_pruned_scan_count_session            | 0              |
| Ndb_api_scan_batch_count_session             | 2              |
| Ndb_api_read_row_count_session               | 2              |
| Ndb_api_trans_local_read_row_count_session   | 2              |
| Ndb_api_adaptive_send_forced_count_session   | 1              |
| Ndb_api_adaptive_send_unforced_count_session | 0              |
| Ndb_api_adaptive_send_deferred_count_session | 0              |
+----------------------------------------------+----------------+
90 rows in set (0.00 sec)

mysql> SELECT * FROM performance_schema.global_status
    ->     WHERE VARIABLE_NAME LIKE 'ndb_api%';
+----------------------------------------------+----------------+
| VARIABLE_NAME                                | VARIABLE_VALUE |
+----------------------------------------------+----------------+
| Ndb_api_wait_exec_complete_count             | 11             |
| Ndb_api_wait_scan_result_count               | 14             |
| Ndb_api_wait_meta_request_count              | 88             |
| Ndb_api_wait_nanos_count                     | 159810484729   |
| Ndb_api_bytes_sent_count                     | 3616           |
| Ndb_api_bytes_received_count                 | 107176         |
| Ndb_api_trans_start_count                    | 10             |
| Ndb_api_trans_commit_count                   | 2              |
| Ndb_api_trans_abort_count                    | 4              |
| Ndb_api_trans_close_count                    | 10             |
| Ndb_api_pk_op_count                          | 6              |
| Ndb_api_uk_op_count                          | 0              |
| Ndb_api_table_scan_count                     | 3              |
| Ndb_api_range_scan_count                     | 1              |
| Ndb_api_pruned_scan_count                    | 0              |
| Ndb_api_scan_batch_count                     | 3              |
| Ndb_api_read_row_count                       | 11             |
| Ndb_api_trans_local_read_row_count           | 9              |
| Ndb_api_adaptive_send_forced_count           | 5              |
| Ndb_api_adaptive_send_unforced_count         | 11             |
| Ndb_api_adaptive_send_deferred_count         | 0              |
| Ndb_api_event_data_count                     | 0              |
| Ndb_api_event_nondata_count                  | 0              |
| Ndb_api_event_bytes_count                    | 0              |
| Ndb_api_event_data_count_injector            | 0              |
| Ndb_api_event_nondata_count_injector         | 0              |
| Ndb_api_event_bytes_count_injector           | 0              |
| Ndb_api_wait_exec_complete_count_slave       | 0              |
| Ndb_api_wait_scan_result_count_slave         | 0              |
| Ndb_api_wait_meta_request_count_slave        | 0              |
| Ndb_api_wait_nanos_count_slave               | 0              |
| Ndb_api_bytes_sent_count_slave               | 0              |
| Ndb_api_bytes_received_count_slave           | 0              |
| Ndb_api_trans_start_count_slave              | 0              |
| Ndb_api_trans_commit_count_slave             | 0              |
| Ndb_api_trans_abort_count_slave              | 0              |
| Ndb_api_trans_close_count_slave              | 0              |
| Ndb_api_pk_op_count_slave                    | 0              |
| Ndb_api_uk_op_count_slave                    | 0              |
| Ndb_api_table_scan_count_slave               | 0              |
| Ndb_api_range_scan_count_slave               | 0              |
| Ndb_api_pruned_scan_count_slave              | 0              |
| Ndb_api_scan_batch_count_slave               | 0              |
| Ndb_api_read_row_count_slave                 | 0              |
| Ndb_api_trans_local_read_row_count_slave     | 0              |
| Ndb_api_adaptive_send_forced_count_slave     | 0              |
| Ndb_api_adaptive_send_unforced_count_slave   | 0              |
| Ndb_api_adaptive_send_deferred_count_slave   | 0              |
| Ndb_api_wait_exec_complete_count_replica     | 0              |
| Ndb_api_wait_scan_result_count_replica       | 0              |
| Ndb_api_wait_meta_request_count_replica      | 0              |
| Ndb_api_wait_nanos_count_replica             | 0              |
| Ndb_api_bytes_sent_count_replica             | 0              |
| Ndb_api_bytes_received_count_replica         | 0              |
| Ndb_api_trans_start_count_replica            | 0              |
| Ndb_api_trans_commit_count_replica           | 0              |
| Ndb_api_trans_abort_count_replica            | 0              |
| Ndb_api_trans_close_count_replica            | 0              |
| Ndb_api_pk_op_count_replica                  | 0              |
| Ndb_api_uk_op_count_replica                  | 0              |
| Ndb_api_table_scan_count_replica             | 0              |
| Ndb_api_range_scan_count_replica             | 0              |
| Ndb_api_pruned_scan_count_replica            | 0              |
| Ndb_api_scan_batch_count_replica             | 0              |
| Ndb_api_read_row_count_replica               | 0              |
| Ndb_api_trans_local_read_row_count_replica   | 0              |
| Ndb_api_adaptive_send_forced_count_replica   | 0              |
| Ndb_api_adaptive_send_unforced_count_replica | 0              |
| Ndb_api_adaptive_send_deferred_count_replica | 0              |
| Ndb_api_wait_exec_complete_count_session     | 0              |
| Ndb_api_wait_scan_result_count_session       | 3              |
| Ndb_api_wait_meta_request_count_session      | 6              |
| Ndb_api_wait_nanos_count_session             | 2022486        |
| Ndb_api_bytes_sent_count_session             | 268            |
| Ndb_api_bytes_received_count_session         | 10332          |
| Ndb_api_trans_start_count_session            | 1              |
| Ndb_api_trans_commit_count_session           | 0              |
| Ndb_api_trans_abort_count_session            | 0              |
| Ndb_api_trans_close_count_session            | 1              |
| Ndb_api_pk_op_count_session                  | 0              |
| Ndb_api_uk_op_count_session                  | 0              |
| Ndb_api_table_scan_count_session             | 1              |
| Ndb_api_range_scan_count_session             | 0              |
| Ndb_api_pruned_scan_count_session            | 0              |
| Ndb_api_scan_batch_count_session             | 2              |
| Ndb_api_read_row_count_session               | 2              |
| Ndb_api_trans_local_read_row_count_session   | 2              |
| Ndb_api_adaptive_send_forced_count_session   | 1              |
| Ndb_api_adaptive_send_unforced_count_session | 0              |
| Ndb_api_adaptive_send_deferred_count_session | 0              |
+----------------------------------------------+----------------+
90 rows in set (0.01 sec)

每个Ndb对象都有自己的计数器。NDB API应用程序可以读取计数器的值,以用于优化或监控。对于使用多个Ndb对象的多线程客户端,可以获取所有属于给定Ndb_cluster_connectionNdb对象的累积视图。

四组这些计数器是公开的。其中一组只应用于当前会话;另外三组是全局的。这与它们的值可以作为 either 会话或全局状态变量在mysql 客户端中不同。这意味着,在使用SHOW STATUS时,指定SESSIONGLOBAL关键字没有影响NDB API统计状态变量的值,每个变量的值都是一样的,无论是从session_statusglobal_status表中获取。

  • 会话计数器(session specific)

    会话计数器与Ndb对象在当前会话中使用的相关。其他 MySQL 客户端使用这些对象不影响这些计数器。

    为了避免与标准 MySQL 会话变量混淆,我们将对应于这些 NDB API 会话计数器的变量称为_session 变量”,带有前导下划线。

  • 副本计数器(global)

    这个计数器集与Ndb对象相关,如果replica SQL线程存在。如果mysqld不作为replica或不使用NDB表,则所有这些计数器都为0。

    我们将相关的状态变量称为_replica变量”(带有前导下划线)。

  • Injector计数器(全局)

    Injector计数器与Ndb对象相关,用于监听集群事件的二进制日志注入线程,即使不写入二进制日志,mysqld仍然继续监听某些事件,如架构变化。

    我们将NDB API Injector计数器对应的状态变量称为_injector变量”(带有前导下划线)。

  • 服务器(全局)计数器(全局)

    这个计数器集与当前使用的Ndb对象相关,这包括所有MySQL客户端应用程序、副本SQL线程(如果存在)、二进制日志注入器和NDButility线程。

    我们将与这些计数器对应的状态变量称为“全局变量”“mysqld级别变量”

您可以通过在变量名称中添加子字符串sessionreplicainjector来获取特定变量的值(加上公共前缀Ndb_api)。对于_session变量,这可以按照以下方式进行:

mysql> SHOW STATUS LIKE 'ndb_api%session';
+----------------------------------------------+---------+
| Variable_name                                | Value   |
+----------------------------------------------+---------+
| Ndb_api_wait_exec_complete_count_session     | 0       |
| Ndb_api_wait_scan_result_count_session       | 3       |
| Ndb_api_wait_meta_request_count_session      | 6       |
| Ndb_api_wait_nanos_count_session             | 2022486 |
| Ndb_api_bytes_sent_count_session             | 268     |
| Ndb_api_bytes_received_count_session         | 10332   |
| Ndb_api_trans_start_count_session            | 1       |
| Ndb_api_trans_commit_count_session           | 0       |
| Ndb_api_trans_abort_count_session            | 0       |
| Ndb_api_trans_close_count_session            | 1       |
| Ndb_api_pk_op_count_session                  | 0       |
| Ndb_api_uk_op_count_session                  | 0       |
| Ndb_api_table_scan_count_session             | 1       |
| Ndb_api_range_scan_count_session             | 0       |
| Ndb_api_pruned_scan_count_session            | 0       |
| Ndb_api_scan_batch_count_session             | 2       |
| Ndb_api_read_row_count_session               | 2       |
| Ndb_api_trans_local_read_row_count_session   | 2       |
| Ndb_api_adaptive_send_forced_count_session   | 1       |
| Ndb_api_adaptive_send_unforced_count_session | 0       |
| Ndb_api_adaptive_send_deferred_count_session | 0       |
+----------------------------------------------+---------+
21 rows in set (0.00 sec)

要获得NDB APImysqld-级别状态变量的列表,请将变量名称过滤为以ndb_api开头并以_count结尾,如下所示:

mysql> SELECT * FROM performance_schema.session_status
    ->     WHERE VARIABLE_NAME LIKE 'ndb_api%count';
+------------------------------------+----------------+
| VARIABLE_NAME                      | VARIABLE_VALUE |
+------------------------------------+----------------+
| NDB_API_WAIT_EXEC_COMPLETE_COUNT   | 4              |
| NDB_API_WAIT_SCAN_RESULT_COUNT     | 3              |
| NDB_API_WAIT_META_REQUEST_COUNT    | 28             |
| NDB_API_WAIT_NANOS_COUNT           | 53756398       |
| NDB_API_BYTES_SENT_COUNT           | 1060           |
| NDB_API_BYTES_RECEIVED_COUNT       | 9724           |
| NDB_API_TRANS_START_COUNT          | 3              |
| NDB_API_TRANS_COMMIT_COUNT         | 2              |
| NDB_API_TRANS_ABORT_COUNT          | 0              |
| NDB_API_TRANS_CLOSE_COUNT          | 3              |
| NDB_API_PK_OP_COUNT                | 2              |
| NDB_API_UK_OP_COUNT                | 0              |
| NDB_API_TABLE_SCAN_COUNT           | 1              |
| NDB_API_RANGE_SCAN_COUNT           | 0              |
| NDB_API_PRUNED_SCAN_COUNT          | 0              |
| NDB_API_SCAN_BATCH_COUNT           | 0              |
| NDB_API_READ_ROW_COUNT             | 2              |
| NDB_API_TRANS_LOCAL_READ_ROW_COUNT | 2              |
| NDB_API_EVENT_DATA_COUNT           | 0              |
| NDB_API_EVENT_NONDATA_COUNT        | 0              |
| NDB_API_EVENT_BYTES_COUNT          | 0              |
+------------------------------------+----------------+
21 rows in set (0.09 sec)

不所有计数器都反映在所有4个状态变量中。对于事件计数器DataEventsRecvdCountNondataEventsRecvdCountEventBytesRecvdCount,只有_injectormysqld-级NDB API状态变量可用:

mysql> SHOW STATUS LIKE 'ndb_api%event%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| Ndb_api_event_data_count_injector    | 0     |
| Ndb_api_event_nondata_count_injector | 0     |
| Ndb_api_event_bytes_count_injector   | 0     |
| Ndb_api_event_data_count             | 0     |
| Ndb_api_event_nondata_count          | 0     |
| Ndb_api_event_bytes_count            | 0     |
+--------------------------------------+-------+
6 rows in set (0.00 sec)

_injector状态变量对任何其他NDB API计数器都没有实现,如下所示:

mysql> SHOW STATUS LIKE 'ndb_api%injector%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| Ndb_api_event_data_count_injector    | 0     |
| Ndb_api_event_nondata_count_injector | 0     |
| Ndb_api_event_bytes_count_injector   | 0     |
+--------------------------------------+-------+
3 rows in set (0.00 sec)

状态变量的名称可以轻松地与相应计数器的名称相关联。每个NDB API统计计数器在以下表格中列出,包括描述,以及对应于该计数器的MySQL服务器状态变量名称。

表25.39 NDB API统计计数器

Counter Name Description Status Variables (by statistic type):
  • 会话

  • 副本(从属)

  • 注入器

  • 服务器

WaitExecCompleteCount 线程等待操作完成而被阻塞的次数。包括所有execute()调用,以及隐式执行的blob操作和自动递增不对客户端可见。
WaitScanResultCount Number of times thread has been blocked while waiting for a scan-based signal, such waiting for additional results, or for a scan to close.
WaitMetaRequestCount Number of times thread has been blocked waiting for a metadata-based signal; this can occur when waiting for a DDL operation or for an epoch to be started (or ended).
WaitNanosCount Total time (in nanoseconds) spent waiting for some type of signal from the data nodes.
BytesSentCount Amount of data (in bytes) sent to the data nodes
BytesRecvdCount Amount of data (in bytes) received from the data nodes
TransStartCount Number of transactions started.
TransCommitCount Number of transactions committed.
TransAbortCount Number of transactions aborted.
TransCloseCount Number of transactions aborted. (This value may be greater than the sum of TransCommitCount and TransAbortCount.)
PkOpCount Number of operations based on or using primary keys. This count includes blob-part table operations, implicit unlocking operations, and auto-increment operations, as well as primary key operations normally visible to MySQL clients.
UkOpCount Number of operations based on or using unique keys.
TableScanCount Number of table scans that have been started. This includes scans of internal tables.
RangeScanCount Number of range scans that have been started.
PrunedScanCount Number of scans that have been pruned to a single partition.
ScanBatchCount Number of batches of rows received. (A batch in this context is a set of scan results from a single fragment.)
ReadRowCount Total number of rows that have been read. Includes rows read using primary key, unique key, and scan operations.
TransLocalReadRowCount Number of rows read from the data same node on which the transaction was being run.
DataEventsRecvdCount Number of row change events received.
NondataEventsRecvdCount Number of events received, other than row change events.
EventBytesRecvdCount Number of bytes of events received.

要查看所有已提交事务的计数—that is, all TransCommitCount 计数器状态变量—you can filter the results of SHOW STATUS for the substring trans_commit_count, like this:

mysql> SHOW STATUS LIKE '%trans_commit_count%';
+------------------------------------+-------+
| Variable_name                      | Value |
+------------------------------------+-------+
| Ndb_api_trans_commit_count_session | 1     |
| Ndb_api_trans_commit_count_slave   | 0     |
| Ndb_api_trans_commit_count         | 2     |
+------------------------------------+-------+
3 rows in set (0.00 sec)

从这里可以确定,在当前mysql 客户端会话中已经提交了1个事务,而在这个mysqld 中自从最后重启以来已经提交了2个事务。

您可以通过比较相应的_session状态变量的值来了解各种NDB API计数器是如何被给定的SQL语句增量的。例如,在这个示例中,我们首先从SHOW STATUS获取初始值,然后在 test 数据库中创建一个名为tNDB 表,该表只有一个列:

mysql> SHOW STATUS LIKE 'ndb_api%session%';
+--------------------------------------------+--------+
| Variable_name                              | Value  |
+--------------------------------------------+--------+
| Ndb_api_wait_exec_complete_count_session   | 2      |
| Ndb_api_wait_scan_result_count_session     | 0      |
| Ndb_api_wait_meta_request_count_session    | 3      |
| Ndb_api_wait_nanos_count_session           | 820705 |
| Ndb_api_bytes_sent_count_session           | 132    |
| Ndb_api_bytes_received_count_session       | 372    |
| Ndb_api_trans_start_count_session          | 1      |
| Ndb_api_trans_commit_count_session         | 1      |
| Ndb_api_trans_abort_count_session          | 0      |
| Ndb_api_trans_close_count_session          | 1      |
| Ndb_api_pk_op_count_session                | 1      |
| Ndb_api_uk_op_count_session                | 0      |
| Ndb_api_table_scan_count_session           | 0      |
| Ndb_api_range_scan_count_session           | 0      |
| Ndb_api_pruned_scan_count_session          | 0      |
| Ndb_api_scan_batch_count_session           | 0      |
| Ndb_api_read_row_count_session             | 1      |
| Ndb_api_trans_local_read_row_count_session | 1      |
+--------------------------------------------+--------+
18 rows in set (0.00 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t (c INT) ENGINE NDBCLUSTER;
Query OK, 0 rows affected (0.85 sec)

现在,您可以执行一个新的SHOW STATUS 语句,并观察变化,如下所示(输出中高亮显示的行):

mysql> SHOW STATUS LIKE 'ndb_api%session%';
+--------------------------------------------+-----------+
| Variable_name                              | Value     |
+--------------------------------------------+-----------+
| Ndb_api_wait_exec_complete_count_session   | 8         |
| Ndb_api_wait_scan_result_count_session     | 0         |
| Ndb_api_wait_meta_request_count_session    | 17        |
| Ndb_api_wait_nanos_count_session           | 706871709 |
| Ndb_api_bytes_sent_count_session           | 2376      |
| Ndb_api_bytes_received_count_session       | 3844      |
| Ndb_api_trans_start_count_session          | 4         |
| Ndb_api_trans_commit_count_session         | 4         |
| Ndb_api_trans_abort_count_session          | 0         |
| Ndb_api_trans_close_count_session          | 4         |
| Ndb_api_pk_op_count_session                | 6         |
| Ndb_api_uk_op_count_session                | 0         |
| Ndb_api_table_scan_count_session           | 0         |
| Ndb_api_range_scan_count_session           | 0         |
| Ndb_api_pruned_scan_count_session          | 0         |
| Ndb_api_scan_batch_count_session           | 0         |
| Ndb_api_read_row_count_session             | 2         |
| Ndb_api_trans_local_read_row_count_session | 1         |
+--------------------------------------------+-----------+
18 rows in set (0.00 sec)

类似地,您可以看到插入SHOW STATUS 语句中NDB API统计计数器的变化:插入行,然后运行同样的SHOW STATUS 语句,如下所示:

mysql> INSERT INTO t VALUES (100);
Query OK, 1 row affected (0.00 sec)

mysql> SHOW STATUS LIKE 'ndb_api%session%';
+--------------------------------------------+-----------+
| Variable_name                              | Value     |
+--------------------------------------------+-----------+
| Ndb_api_wait_exec_complete_count_session   | 11        |
| Ndb_api_wait_scan_result_count_session     | 6         |
| Ndb_api_wait_meta_request_count_session    | 20        |
| Ndb_api_wait_nanos_count_session           | 707370418 |
| Ndb_api_bytes_sent_count_session           | 2724      |
| Ndb_api_bytes_received_count_session       | 4116      |
| Ndb_api_trans_start_count_session          | 7         |
| Ndb_api_trans_commit_count_session         | 6         |
| Ndb_api_trans_abort_count_session          | 0         |
| Ndb_api_trans_close_count_session          | 7         |
| Ndb_api_pk_op_count_session                | 8         |
| Ndb_api_uk_op_count_session                | 0         |
| Ndb_api_table_scan_count_session           | 1         |
| Ndb_api_range_scan_count_session           | 0         |
| Ndb_api_pruned_scan_count_session          | 0         |
| Ndb_api_scan_batch_count_session           | 0         |
| Ndb_api_read_row_count_session             | 3         |
| Ndb_api_trans_local_read_row_count_session | 2         |
+--------------------------------------------+-----------+
18 rows in set (0.00 sec)

我们可以从这些结果中做出以下观察: