NDB 在 MySQL Performance Schema 中提供有關 ndbcluster
外掛程式執行緒和交易批次記憶體檢測的資訊。這些功能將在以下章節中詳細說明。
ndbcluster
外掛程式執行緒在 Performance Schema threads
表格中可見,如下列查詢所示
mysql> SELECT name, type, thread_id, thread_os_id
-> FROM performance_schema.threads
-> WHERE name LIKE '%ndbcluster%'\G
+----------------------------------+------------+-----------+--------------+
| name | type | thread_id | thread_os_id |
+----------------------------------+------------+-----------+--------------+
| thread/ndbcluster/ndb_binlog | BACKGROUND | 30 | 11980 |
| thread/ndbcluster/ndb_index_stat | BACKGROUND | 31 | 11981 |
| thread/ndbcluster/ndb_metadata | BACKGROUND | 32 | 11982 |
+----------------------------------+------------+-----------+--------------+
threads
表格顯示此處列出的所有三個執行緒
ndb_binlog
:二進位記錄執行緒ndb_index_stat
:索引統計執行緒ndb_metadata
:中繼資料執行緒
這些執行緒也會依名稱顯示在 setup_threads
表格中。
執行緒名稱使用
格式顯示在 prefix
/plugin_name
/thread_name
threads
和 setup_threads
表格的 name
欄中。prefix
是由 performance_schema
引擎判定的物件類型,外掛程式執行緒為 thread
(請參閱執行緒檢測元素)。plugin_name
是 ndbcluster
。thread_name
是執行緒的獨立名稱 (ndb_binlog
、ndb_index_stat
或 ndb_metadata
)。
使用 threads
或 setup_threads
表格中給定執行緒的執行緒 ID 或 OS 執行緒 ID,可以從 Performance Schema 取得有關外掛程式執行和資源使用的許多資訊。此範例顯示如何透過聯結 threads
和 memory_summary_by_thread_by_event_name
表格,從 mem_root
區塊取得由 ndbcluster
外掛程式建立的執行緒所配置的記憶體量
mysql> SELECT
-> t.name,
-> m.sum_number_of_bytes_alloc,
-> IF(m.sum_number_of_bytes_alloc > 0, "true", "false") AS 'Has allocated memory'
-> FROM performance_schema.memory_summary_by_thread_by_event_name m
-> JOIN performance_schema.threads t
-> ON m.thread_id = t.thread_id
-> WHERE t.name LIKE '%ndbcluster%'
-> AND event_name LIKE '%THD::main_mem_root%';
+----------------------------------+---------------------------+----------------------+
| name | sum_number_of_bytes_alloc | Has allocated memory |
+----------------------------------+---------------------------+----------------------+
| thread/ndbcluster/ndb_binlog | 20576 | true |
| thread/ndbcluster/ndb_index_stat | 0 | false |
| thread/ndbcluster/ndb_metadata | 8240 | true |
+----------------------------------+---------------------------+----------------------+
您可以透過查詢 Performance Schema memory_summary_by_thread_by_event_name
表格,查看用於交易批次的記憶體量,類似於此處所示
mysql> SELECT EVENT_NAME
-> FROM performance_schema.memory_summary_by_thread_by_event_name
-> WHERE THREAD_ID = PS_CURRENT_THREAD_ID()
-> AND EVENT_NAME LIKE 'memory/ndbcluster/%';
+-------------------------------------------+
| EVENT_NAME |
+-------------------------------------------+
| memory/ndbcluster/Thd_ndb::batch_mem_root |
+-------------------------------------------+
1 row in set (0.01 sec)
ndbcluster
交易記憶體檢測也顯示在 Performance Schema setup_instruments
表格中,如下所示
mysql> SELECT * from performance_schema.setup_instruments
-> WHERE NAME LIKE '%ndb%'\G
*************************** 1. row ***************************
NAME: memory/ndbcluster/Thd_ndb::batch_mem_root
ENABLED: YES
TIMED: NULL
PROPERTIES:
VOLATILITY: 0
DOCUMENTATION: Memory used for transaction batching
1 row in set (0.01 sec)