### 23.6.16 ndbcluster Plugin Threads

[]()[]()[]()

 Beginning with with NDB 8.0.29, `ndbcluster` plugin threads are visible in the Performance Schema [`threads`](performance-schema-threads-table.html) 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 |
+----------------------------------+------------+-----------+--------------+
```

 The `threads` table shows all three of the threads listed here:

* `ndb_binlog`: Binary logging thread

* `ndb_index_stat`: Index statistics thread

* `ndb_metadata`: Metadata thread

 These threads are also shown by name in the [`setup_threads`](performance-schema-setup-threads-table.html) table.

 Thread names are shown in the `name` column of the `threads` and `setup_threads` tables using the format `*`prefix`*/*`plugin_name`*/*`thread_name`*`. *`prefix`*, the object type as determined by the [`performance_schema`](performance-schema.html) engine, is `thread` for plugin threads (see [Thread Instrument Elements](performance-schema-instrument-naming.html#performance-schema-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`).

 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`](performance-schema-memory-summary-tables.html) 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                 |
+----------------------------------+---------------------------+----------------------+
```

