文件首頁
MySQL 9.0 參考手冊
相關文件 下載本手冊
PDF (美式信紙) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 258.2Kb
Man Pages (Zip) - 365.3Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 參考手冊  /  ...  /  NDB API 統計計數器和變數

25.6.16 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             | 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)

這些狀態變數也可從效能架構 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_connection 的所有 Ndb 物件取得計數器的總和檢視。

公開了四組這些計數器。一組僅適用於目前的階段作業;另外 3 組是全域的。 儘管它們的值可以作為 mysql 用戶端中的階段作業或全域狀態變數取得。這表示指定 SHOW STATUSSESSIONGLOBAL 關鍵字對 NDB API 統計狀態變數報告的值沒有影響,並且無論該值是從 session_statusglobal_status 資料表的對等欄取得,每個這些變數的值都相同。

  • 階段作業計數器 (階段作業特定)

    階段作業計數器與目前階段作業 (僅) 使用的 Ndb 物件相關。其他 MySQL 用戶端對此類物件的使用不會影響這些計數。

    為了盡量減少與標準 MySQL 階段作業變數的混淆,我們將對應於這些 NDB API 階段作業計數器的變數稱為 _session 變數,並帶有前導底線。

  • 複本計數器 (全域)

    這組計數器與複本 SQL 執行緒 (如果有的話) 使用的 Ndb 物件相關。如果此 mysqld 不作為複本,或不使用 NDB 資料表,則所有這些計數均為 0。

    我們將相關的狀態變數稱為 _replica 變數 (帶有前導底線)。

  • 注入器計數器 (全域)

    注入器計數器與二進位日誌注入器執行緒用來接聽叢集事件的 Ndb 物件相關。即使在不寫入二進位日誌時,附加到 NDB Cluster 的 mysqld 處理程序仍會繼續接聽某些事件,例如架構變更。

    我們將對應於 NDB API 注入器計數器的狀態變數稱為 _injector 變數 (帶有前導底線)。

  • 伺服器 (全域) 計數器 (全域)

    這組計數器與此 mysqld 目前使用的所有 Ndb 物件相關。這包括所有 MySQL 用戶端應用程式、複本 SQL 執行緒 (如果有的話)、二進位日誌注入器和 NDB 公用程式執行緒。

    我們將對應於這些計數器的狀態變數稱為 全域變數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 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 組狀態變數中。對於事件計數器 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)

對於任何其他 NDB API 計數器,未實作 _injector 狀態變數,如下所示

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 統計計數器

計數器名稱 描述 狀態變數 (依統計類型)
  • 階段作業

  • 複本 (從屬)

  • 注入器

  • 伺服器

WaitExecCompleteCount 執行緒在等待操作完成執行時被封鎖的次數。包括所有 execute() 呼叫以及對用戶端不可見的 blob 操作和自動遞增的隱含執行。
WaitScanResultCount 執行緒在等待以掃描為基礎的信號時被封鎖的次數,例如等待其他結果,或等待掃描關閉。
WaitMetaRequestCount 執行緒在等待以中繼資料為基礎的信號時被封鎖的次數;這可能會在等待 DDL 操作或等待啟動 (或結束) epoch 時發生。
WaitNanosCount 等待來自資料節點的某種信號所花費的總時間 (以奈秒為單位)。
BytesSentCount 傳送至資料節點的資料量 (以位元組為單位)
BytesRecvdCount 從資料節點接收的資料量 (以位元組為單位)
TransStartCount 啟動的交易數量。
TransCommitCount 已提交的交易數量。
TransAbortCount 已中止的交易數量。
TransCloseCount 已中止的交易數量。(此值可能大於 TransCommitCountTransAbortCount 的總和。)
PkOpCount 基於或使用主鍵的操作數量。此計數包括 blob 部分表格操作、隱式解鎖操作和自動遞增操作,以及通常對 MySQL 客戶端可見的主鍵操作。
UkOpCount 基於或使用唯一鍵的操作數量。
TableScanCount 已啟動的表格掃描數量。這包括內部表格的掃描。
RangeScanCount 已啟動的範圍掃描數量。
PrunedScanCount 已修剪到單個分割區的掃描數量。
ScanBatchCount 接收的行批次數量。(在此上下文中,批次是指來自單個片段的一組掃描結果。)
ReadRowCount 已讀取的行總數。包括使用主鍵、唯一鍵和掃描操作讀取的行。
TransLocalReadRowCount 從執行交易的同一節點讀取的行數。
DataEventsRecvdCount 接收到的行變更事件數量。
NondataEventsRecvdCount 接收到的事件數量,行變更事件除外。
EventBytesRecvdCount 接收到的事件位元組數。

要查看所有已提交交易的計數 (即所有 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 資料庫中建立一個名為 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)

同樣地,您可以查看將列插入 t 所造成的 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)

我們可以從這些結果中得出許多觀察結果