NDB 8.0 在 MySQL Performance Schema 中提供了有关线程和事务内存使用的信息;NDB 8.0.29 添加了
ndbcluster
插件线程,NDB 8.0.30 添加了事务批处理内存检测。这些功能将在以下各节中进行更详细的描述。
从 NDB 8.0.29 开始,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
表中按名称显示。
线程名称使用格式
显示在和
表的name
列中。
,由引擎确定的对象类型,用于插件线程(请参阅
线程工具元素)。的是
。
是线程的独立名称(、
或
)。
threads
setup_threads
prefix
/plugin_name
/thread_name
prefix
performance_schema
thread
plugin_name
ndbcluster
thread_name
ndb_binlog
ndb_index_stat
ndb_metadata
threads
使用或表
中给定线程的线程 ID 或操作系统线程 ID,
setup_threads
可以从 Performance Schema 中获取有关插件执行和资源使用情况的大量信息。此示例显示如何通过连接和
表
从arena
获取ndbcluster
插件创建的线程分配的内存量:mem_root
threads
memory_summary_by_thread_by_event_name
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 |
+----------------------------------+---------------------------+----------------------+
从 NDB 8.0.30 开始,您可以通过查询 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)