MySQL 8.0.39
Source Code Documentation
|
To implement a new performance schema table, two independent problems need to be resolved:
The storage engine interface is used to implement the former. Various design patterns can be used to resolve the later.
The performance schema engine, ha_perfschema
, exposes performance schema tables to the MySQL server. Tables are implemented by sub classing PFS_engine_table
.
The access pattern is always the same for all performance schema tables, and does not depend on what data is exposed, only on how it is exposed.
An application query in general just executes code in the server. Data may of may not be collected in this code path, see next for possible patterns.
Static data does not need to be collected, because it is already known. In this simple case, the table implementation just exposes some internal structure.
An example of table using this pattern is table_setup_consumers
.
When a table implementation exposes collected data:
Note that access to the internal buffer is lock-free.
This pattern:
This pattern should be used only when data is not available by other means.
An example of table using this pattern is table_mutex_instances
.
When a table implementation exposes internal state:
This pattern:
To prevent stalls, by locking the server structure for a long time, the data is typically copied once (the table is 'materialized') before iterating on it.
If this pattern is possible (aka, the data already exists and can be inspected), is it the preferred implementation, which results in the least overhead.
An example of table using this pattern is table_host_cache
.