有許多類型的統計計數器可用,與 Ndb
物件執行或影響的動作相關。這些動作包括啟動和關閉(或中止)交易;主鍵和唯一鍵操作;表格、範圍和修剪掃描;等待各種操作完成時被封鎖的執行緒;以及 NDBCLUSTER
發送和接收的資料與事件。每當呼叫 NDB API 或將資料傳送到資料節點或由資料節點接收資料時,計數器會在 NDB 核心內遞增。mysqld 將這些計數器公開為系統狀態變數;其值可以在 SHOW STATUS
的輸出中讀取,或透過查詢效能綱要 session_status
或 global_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_status
和 global_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 STATUS
的 SESSION
或 GLOBAL
關鍵字,對 NDB API 統計狀態變數報告的值沒有影響,而且每個變數的值都相同,無論該值是從 session_status
或 global_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 層級變數」。
您可以使用變數名稱中額外篩選的子字串 session
、replica
或 injector
(以及通用前綴 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 組狀態變數中。對於事件計數器 DataEventsRecvdCount
、NondataEventsRecvdCount
和 EventBytesRecvdCount
,只有 _injector
和 mysqld 層級的 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 統計計數器
計數器名稱 | 描述 | 狀態變數 (依統計類型)
|
---|---|---|
WaitExecCompleteCount |
執行操作完成時,執行緒被封鎖等待的次數。包含所有 execute() 呼叫,以及對客戶端不可見的 blob 操作和自動遞增的隱式執行。 |
|
WaitScanResultCount |
執行緒在等待基於掃描的信號時被封鎖的次數,例如等待額外的結果或掃描關閉。 | |
WaitMetaRequestCount |
執行緒在等待基於元數據的信號時被封鎖的次數;這可能發生在等待 DDL 操作或等待 epoch 開始(或結束)時。 | |
WaitNanosCount |
等待來自數據節點的某種信號所花費的總時間(以奈秒為單位)。 | |
BytesSentCount |
傳送到數據節點的數據量(以位元組為單位) | |
BytesRecvdCount |
從數據節點接收的數據量(以位元組為單位) | |
TransStartCount |
啟動的事務數量。 | |
TransCommitCount |
提交的事務數量。 | |
TransAbortCount |
中止的事務數量。 | |
TransCloseCount |
中止的事務數量。(此值可能大於 TransCommitCount 和 TransAbortCount 的總和。) |
|
PkOpCount |
基於主鍵或使用主鍵的操作次數。此計數包括 blob 部分表格操作、隱式解鎖操作和自動遞增操作,以及通常對 MySQL 客戶端可見的主鍵操作。 | |
UkOpCount |
基於唯一鍵或使用唯一鍵的操作次數。 | |
TableScanCount |
已啟動的表格掃描次數。這包括內部表格的掃描。 | |
RangeScanCount |
已啟動的範圍掃描次數。 | |
PrunedScanCount |
已修剪到單個分區的掃描次數。 | |
ScanBatchCount |
接收到的行批次數。(在此上下文中,批次是來自單個片段的一組掃描結果。) | |
ReadRowCount |
已讀取的總行數。包括使用主鍵、唯一鍵和掃描操作讀取的行。 | |
TransLocalReadRowCount |
從執行事務的同一節點讀取的行數。 | |
DataEventsRecvdCount |
接收到的行變更事件數。 | |
NondataEventsRecvdCount |
接收到的事件數,行變更事件除外。 | |
EventBytesRecvdCount |
接收到的事件位元組數。 |
若要查看已提交的事務的所有計數,也就是所有 TransCommitCount
計數器狀態變數,您可以針對子字串 trans_commit_count
過濾 SHOW STATUS
的結果,如下所示
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
資料庫中建立一個名為 t
的 NDB
表格,該表格具有單一欄
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)
我們可以從這些結果中進行一些觀察
雖然我們建立
t
時沒有明確的主鍵,但在執行此操作時執行了 5 個主鍵操作(Ndb_api_pk_op_count_session
的「之前」和「之後」值之差,或 6 減 1)。這反映了所有使用NDB
儲存引擎的表格的功能:建立隱藏的主鍵。藉由比較
Ndb_api_wait_nanos_count_session
的連續值,我們可以發現,實作CREATE TABLE
陳述式的 NDB API 操作等待來自資料節點的回應時間要長得多(706871709 - 820705 = 706051004 奈秒,或約 0.7 秒),而INSERT
執行的時間則短得多(707370418 - 706871709 = 498709 奈秒,或約 0.0005 秒)。mysql 用戶端中回報的這些陳述式的執行時間與這些數字大致相關。在時間解析度不足(奈秒)的平台上,由於執行速度非常快的 SQL 陳述式導致的
WaitNanosCount
NDB API 計數器值的小幅變更,可能不一定會顯示在Ndb_api_wait_nanos_count_session
、Ndb_api_wait_nanos_count_replica
或Ndb_api_wait_nanos_count
的值中。INSERT
陳述式遞增了ReadRowCount
和TransLocalReadRowCount
NDB API 統計資料計數器,這反映在Ndb_api_read_row_count_session
和Ndb_api_trans_local_read_row_count_session
的值增加中。