• 首页
  • css3教程
  • html5教程
  • jQuery手册
  • vue手册
  • php手册
  • MySQL手册
  • apache手册
  • redis手册
  • NDB API统计信息计数器和变量

    与由Ndb对象执行或影响对象的动作有关的多种统计计数器是可用的。这些动作包括开始和关闭(或中止)交易;主键和唯一键操作;表,范围和修剪扫描;等待各种操作完成时线程被阻塞;以及由发送和接收的数据和事件NDBCLUSTER。每当进行NDB API调用或数据节点发送或接收数据时,NDB内核中的计数器就会增加。mysqld将这些计数器公开为系统状态变量;可以在的输出中读取其值,也可以SHOW STATUS通过查询性能模式session_statusglobal_status表。通过比较对NDB表进行操作的语句之前和之后的值,可以观察在API级别上采取的相应操作,从而观察执行该语句的成本。

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

    mysql> SHOW STATUS LIKE 'ndb_api%';
    +--------------------------------------------	+----------	+
    | Variable_name	| Value	|
    +--------------------------------------------	+----------	+
    | Ndb_api_wait_exec_complete_count_session	| 0	|
    | Ndb_api_wait_scan_result_count_session	| 0	|
    | Ndb_api_wait_meta_request_count_session	| 0	|
    | Ndb_api_wait_nanos_count_session	| 0	|
    | Ndb_api_bytes_sent_count_session	| 0	|
    | Ndb_api_bytes_received_count_session	| 0	|
    | Ndb_api_trans_start_count_session	| 0	|
    | Ndb_api_trans_commit_count_session	| 0	|
    | Ndb_api_trans_abort_count_session	| 0	|
    | Ndb_api_trans_close_count_session	| 0	|
    | Ndb_api_pk_op_count_session	| 0	|
    | 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	| 0	|
    | Ndb_api_trans_local_read_row_count_session	| 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_wait_exec_complete_count	| 2	|
    | Ndb_api_wait_scan_result_count	| 3	|
    | Ndb_api_wait_meta_request_count	| 27	|
    | Ndb_api_wait_nanos_count	| 45612023	|
    | Ndb_api_bytes_sent_count	| 992	|
    | Ndb_api_bytes_received_count	| 9640	|
    | Ndb_api_trans_start_count	| 2	|
    | Ndb_api_trans_commit_count	| 1	|
    | Ndb_api_trans_abort_count	| 0	|
    | Ndb_api_trans_close_count	| 2	|
    | Ndb_api_pk_op_count	| 1	|
    | 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	| 1	|
    | Ndb_api_trans_local_read_row_count	| 1	|
    | Ndb_api_event_data_count	| 0	|
    | Ndb_api_event_nondata_count	| 0	|
    | Ndb_api_event_bytes_count	| 0	|
    +--------------------------------------------	+----------	+
    60 rows in set (0.02 sec)
    

    这些状态变量也可以从性能架构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_SESSION	| 2	|
    | NDB_API_WAIT_SCAN_RESULT_COUNT_SESSION	| 0	|
    | NDB_API_WAIT_META_REQUEST_COUNT_SESSION	| 1	|
    | NDB_API_WAIT_NANOS_COUNT_SESSION	| 8144375	|
    | NDB_API_BYTES_SENT_COUNT_SESSION	| 68	|
    | NDB_API_BYTES_RECEIVED_COUNT_SESSION	| 84	|
    | 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	|
    | 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_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	|
    +--------------------------------------------	+----------------	+
    60 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_SESSION	| 2	|
    | NDB_API_WAIT_SCAN_RESULT_COUNT_SESSION	| 0	|
    | NDB_API_WAIT_META_REQUEST_COUNT_SESSION	| 1	|
    | NDB_API_WAIT_NANOS_COUNT_SESSION	| 8144375	|
    | NDB_API_BYTES_SENT_COUNT_SESSION	| 68	|
    | NDB_API_BYTES_RECEIVED_COUNT_SESSION	| 84	|
    | 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	|
    | 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_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	|
    +--------------------------------------------	+----------------	+
    60 rows in set (0.00 sec)
    

    每个Ndb对象都有其自己的计数器。NDB API应用程序可以读取计数器的值以用于优化或监视。对于同时使用多个Ndb对象的多线程客户端,也可以Ndb从属于给定的所有对象中获得计数器的汇总视图Ndb_cluster_connection

    这些计数器有四套。一组仅适用于当前会话;其他3个是全球性的。尽管这是可以在mysql客户端中将它们的值作为会话或全局状态变量获取的事实。这意味着将SESSIONor GLOBAL关键字指定SHOW STATUS为对NDB API统计信息状态变量报告的值没有影响,并且无论这些变量的值是从the session_statusglobal_status表的等效列中获取的,这些变量的值均相同。

    • 会话计数器(特定于会话)

      会话计数器与Ndb(仅)当前会话正在使用的对象有关。其他MySQL客户端对此类对象的使用不会影响这些计数。

      为了最大程度地减少与标准MySQL会话变量的混淆,我们将与这些NDB API会话计数器相对应的变量称为“_session变量”,并带有下划线。

    • 从站计数器(全局)

      这组计数器与Ndb复制从属SQL线程(如果有)使用的对象有关。如果此mysqld不充当复制从属或不使用NDB表,则所有这些计数均为0。

      我们将相关的状态变量称为“_slave变量”(带下划线)。

    • 进样器计数器(全局)

      注入器计数器与Ndb二进制日志注入器线程用于侦听群集事件的对象有关。即使不编写二进制日志,连接到NDB群集的mysqld进程也会继续侦听某些事件,例如架构更改。

      我们将与NDB API注入器计数器相对应的状态变量称为“_injector变量”(带下划线)。

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

      这组计数器与Ndbmysqld当前使用的所有对象有关。这包括所有MySQL客户端应用程序,从SQL线程(如果有),二进制日志注入器和NDB实用程序线程。

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

    可以通过为子串附加滤波获得用于特定的一组变量的值sessionslaveinjector在变量名(连同公共前缀Ndb_api)。对于_session变量,可以按如下所示进行:

    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	| 1	|
    | Ndb_api_wait_nanos_count_session	| 8144375	|
    | Ndb_api_bytes_sent_count_session	| 68	|
    | Ndb_api_bytes_received_count_session	| 84	|
    | 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.50 sec)
    

    要获取NDB API mysqld级状态变量的列表,请过滤以开头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组状态变量中。对于事件计数器DataEventsRecvdCountNondataEventsRecvdCount以及EventBytesRecvdCount,只有_injectormysqld的-level 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服务器状态变量的描述和名称。

    NDB API统计信息计数器

    柜台名称描述状态变量(按统计类型):
    • 届会
    • 奴隶
    • 注射器
    • 服务器
    WaitExecCompleteCount在等待操作执行完成时线程被阻塞的次数。包括所有execute()调用以及对Blob操作和客户端不可见的自动增量的隐式执行。
    • Ndb_api_wait_exec_complete_count_session
    • Ndb_api_wait_exec_complete_count_slave
    • [没有]
    • Ndb_api_wait_exec_complete_count
    WaitScanResultCount等待基于扫描的信号(例如,等待其他结果或关闭扫描)时线程被阻塞的次数。
    • Ndb_api_wait_scan_result_count_session
    • Ndb_api_wait_scan_result_count_slave
    • [没有]
    • Ndb_api_wait_scan_result_count
    WaitMetaRequestCount线程被阻塞等待基于元数据的信号的次数;在等待DDL操作或开始(或结束)某个时期时,可能会发生这种情况。
    • Ndb_api_wait_meta_request_count_session
    • Ndb_api_wait_meta_request_count_slave
    • [没有]
    • Ndb_api_wait_meta_request_count
    WaitNanosCount等待数据节点发出某种类型的信号所花费的总时间(以纳秒为单位)。
    • Ndb_api_wait_nanos_count_session
    • Ndb_api_wait_nanos_count_slave
    • [没有]
    • Ndb_api_wait_nanos_count
    BytesSentCount发送到数据节点的数据量(以字节为单位)
    • Ndb_api_bytes_sent_count_session
    • Ndb_api_bytes_sent_count_slave
    • [没有]
    • Ndb_api_bytes_sent_count
    BytesRecvdCount从数据节点接收的数据量(以字节为单位)
    • Ndb_api_bytes_received_count_session
    • Ndb_api_bytes_received_count_slave
    • [没有]
    • Ndb_api_bytes_received_count
    TransStartCount开始的交易数。
    • Ndb_api_trans_start_count_session
    • Ndb_api_trans_start_count_slave
    • [没有]
    • Ndb_api_trans_start_count
    TransCommitCount提交的事务数。
    • Ndb_api_trans_commit_count_session
    • Ndb_api_trans_commit_count_slave
    • [没有]
    • Ndb_api_trans_commit_count
    TransAbortCount中止的事务数。
    • Ndb_api_trans_abort_count_session
    • Ndb_api_trans_abort_count_slave
    • [没有]
    • Ndb_api_trans_abort_count
    TransCloseCount中止的事务数。(此值可以比的总和TransCommitCountTransAbortCount)。
    • Ndb_api_trans_close_count_session
    • Ndb_api_trans_close_count_slave
    • [没有]
    • Ndb_api_trans_close_count
    PkOpCount基于或使用主键的操作数。此计数包括Blob部分表操作,隐式解锁操作和自动增量操作,以及通常对MySQL客户端可见的主键操作。
    • Ndb_api_pk_op_count_session
    • Ndb_api_pk_op_count_slave
    • [没有]
    • Ndb_api_pk_op_count
    UkOpCount基于或使用唯一键的操作数。
    • Ndb_api_uk_op_count_session
    • Ndb_api_uk_op_count_slave
    • [没有]
    • Ndb_api_uk_op_count
    TableScanCount已启动的表扫描数。这包括内部表的扫描。
    • Ndb_api_table_scan_count_session
    • Ndb_api_table_scan_count_slave
    • [没有]
    • Ndb_api_table_scan_count
    RangeScanCount已开始的范围扫描数。
    • Ndb_api_range_scan_count_session
    • Ndb_api_range_scan_count_slave
    • [没有]
    • Ndb_api_range_scan_count
    PrunedScanCount已修剪到单个分区的扫描数。
    • Ndb_api_pruned_scan_count_session
    • Ndb_api_pruned_scan_count_slave
    • [没有]
    • Ndb_api_pruned_scan_count
    ScanBatchCount收到的行的批次数。(在这种情况下,批处理是来自单个片段的一组扫描结果。)
    • Ndb_api_scan_batch_count_session
    • Ndb_api_scan_batch_count_slave
    • [没有]
    • Ndb_api_scan_batch_count
    ReadRowCount已读取的总行数。包括使用主键,唯一键和扫描操作读取的行。
    • Ndb_api_read_row_count_session
    • Ndb_api_read_row_count_slave
    • [没有]
    • Ndb_api_read_row_count
    TransLocalReadRowCount从运行事务的同一节点的数据读取的行数。
    • Ndb_api_trans_local_read_row_count_session
    • Ndb_api_trans_local_read_row_count_slave
    • [没有]
    • Ndb_api_trans_local_read_row_count
    DataEventsRecvdCount收到的行更改事件数。
    • [没有]
    • [没有]
    • Ndb_api_event_data_count_injector
    • Ndb_api_event_data_count
    NondataEventsRecvdCount收到的事件数,但行更改事件除外。
    • [没有]
    • [没有]
    • Ndb_api_event_nondata_count_injector
    • Ndb_api_event_nondata_count
    EventBytesRecvdCount接收到的事件的字节数。
    • [没有]
    • [没有]
    • Ndb_api_event_bytes_count_injector
    • Ndb_api_event_bytes_count

    要参见已提交事务的所有计数(即所有TransCommitCount计数器状态变量),您可以过滤SHOW STATUS子字符串的结果trans_commit_count,如下所示:

    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执行语句前后相应状态变量的值,可以看到给定的SQL语句如何增加各种NDB API计数器。在此示例中,从获得初始值之后SHOW STATUS,我们在test数据库中创建一个NDB名为的表,该表t具有单个列:

    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)
    

    同样,您可以看到NDB API统计信息计数器中的更改,该更改是由于将一行t插入以下内容而引起的:插入该行,然后运行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)
    

    我们可以从这些结果中得出许多结论:

    • 尽管我们创建t时没有显式主键,但这样做却执行了5次主键操作(“ before ”和“ after ”值的差值为Ndb_api_pk_op_count_session6或1)。这反映了隐藏主键的创建,这是使用NDB存储引擎的所有表的功能。
    • 通过比较连续的值Ndb_api_wait_nanos_count_session,我们可以看到,实现了NDB API操作CREATE TABLE语句等待更长的时间(706871709 - 820705 = 706051004纳秒,或约0.7秒)响应从不是由执行这些数据节点INSERT(707370418 - 706871709 = 498709 ns或大约.0005秒)。在mysql客户端中为这些语句报告的执行时间与这些数字大致相关。

      在没有足够的(纳秒)的时间分辨率平台,小的变化在价值WaitNanosCount由于SQL语句非常迅速执行NDB API计数器可能并不总是可见的值Ndb_api_wait_nanos_count_sessionNdb_api_wait_nanos_count_slaveNdb_api_wait_nanos_count

    • INSERT声明同时增加了对ReadRowCountTransLocalReadRowCountNDB API统计计数器,通过增加的值作为反映Ndb_api_read_row_count_sessionNdb_api_trans_local_read_row_count_session