NDB 在 MySQL 性能模式中提供关于 ndbcluster 插件线程和事务批处理内存仪器的信息。这些功能将在下面的各节中详细描述。NDB provides information in the MySQL Performance Schema about
ndbcluster plugin threads and instrumenting for
transaction batch memory. These features are described in greater
detail in the sections which follow.
ndbcluster 插件线程可在性能模式 threads 表中查看,如以下查询所示:ndbcluster plugin threads are visible in the
Performance Schema threads table,
as shown in the following query:
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 表显示了此处列出的三种线程:The threads table shows all three of the
threads listed here:
ndb_binlog:二进制日志线程ndb_binlog: Binary logging threadndb_index_stat:索引统计线程ndb_index_stat: Index statistics threadndb_metadata:元数据线程ndb_metadata: Metadata thread
这些线程的名称也在 setup_threads 表中显示。These threads are also shown by name in the
setup_threads table.
Thread names are shown in the name column of
the threads以及setup_threads tables using the format
.
prefix/plugin_name/thread_nameprefix, the object type as determined
by the performance_schema engine,
is thread for plugin threads (see
Thread Instrument Elements).
The plugin_name is
ndbcluster.
thread_name is the standalone name of
the thread (ndb_binlog,
ndb_index_stat,或ndb_metadata).Thread names are shown in the name column of
the threads and
setup_threads tables using the format
.
prefix/plugin_name/thread_nameprefix, the object type as determined
by the performance_schema engine,
is thread for plugin threads (see
Thread Instrument Elements).
The plugin_name is
ndbcluster.
thread_name is the standalone name of
the thread (ndb_binlog,
ndb_index_stat, or
ndb_metadata).
使用 threads 或 setup_threads 表中给定线程的线程 ID 或操作系统线程 ID,可以从性能模式(Performance Schema)获取有关插件执行和资源使用的相当多的信息。此示例展示了如何通过连接 threads 和 memory_summary_by_thread_by_event_name 表,获取 ndbcluster 插件创建的线程从 mem_root 内存区分配的内存量:Using the thread ID or OS thread ID for a given thread in the
threads or setup_threads
table, it is possible to obtain considerable information from
Performance Schema about plugin execution and resource usage.
This example shows how to obtain the amount of memory allocated
by the threads created by the ndbcluster
plugin from the mem_root arena by joining the
threads and
memory_summary_by_thread_by_event_name
tables:
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 | +----------------------------------+---------------------------+----------------------+
您可以通过查询性能模式 memory_summary_by_thread_by_event_name 表来查看事务批处理使用的内存量,如下所示:You can see the amount of memory used for transaction batching
by querying the Performance Schema
memory_summary_by_thread_by_event_name
table, similar to what is shown here:
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 事务内存仪表也可以在性能模式 setup_instruments 表中看到,如下所示:The ndbcluster transaction memory instrument
is also visible in the Performance Schema
setup_instruments table, as shown
here:
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)