Performance Schema Overview
The Performance Schema is a feature for monitoring server performance.
Versions in MariaDB
Performance Schema Version | Introduced |
---|---|
5.6.43 | MariaDB 10.0.38 |
5.6.42 | MariaDB 10.0.37 |
5.6.39 | MariaDB 10.0.34 |
5.6.38 | MariaDB 10.0.33 |
5.6.37 | MariaDB 10.1.26, MariaDB 10.0.32 |
5.6.36 | MariaDB 10.2.7, MariaDB 10.1.24, MariaDB 10.0.31 |
5.6.35 | MariaDB 10.1.21, MariaDB 10.0.29 |
5.6.33 | MariaDB 10.2.5, MariaDB 10.1.18, MariaDB 10.0.28 |
5.6.32 | MariaDB 10.1.17, MariaDB 10.0.27 |
5.6.31 | MariaDB 10.1.15, MariaDB 10.0.26 |
5.6.30 | MariaDB 10.1.14, MariaDB 10.0.25 |
5.6.29 | MariaDB 10.1.12, MariaDB 10.0.24 |
5.6.28 | MariaDB 10.0.23 |
5.6.27 | MariaDB 10.1.8 , MariaDB 10.0.22 |
5.6.26 | MariaDB 10.1.7, MariaDB 10.0.21 |
5.6.25 | MariaDB 10.1.6, MariaDB 10.0.20 |
5.6.24 | MariaDB 10.0.18 |
5.6.20 | MariaDB 10.0.13 |
5.6.17 | MariaDB 10.0.11 |
Introduction
It is implemented as a storage engine, and so will appear in the list of storage engines available.
SHOW ENGINES; +--------------------+---------+----------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------+--------------+------+------------+ | ... | | | | | | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | ... | | | | | | +--------------------+---------+----------------------------------+--------------+------+------------+
However, performance_schema
is not a regular storage engine for storing data, it's a mechanism for implementing the Performance Schema feature.
The storage engine contains a database called performance_schema
, which in turn consists of a number of tables that can be queried with regular SQL statements, returning specific performance information.
USE performance_schema
SHOW TABLES; +----------------------------------------------------+ | Tables_in_performance_schema | +----------------------------------------------------+ | accounts | ... | users | +----------------------------------------------------+ 80 rows in set (0.00 sec)
See List of Performance Schema Tables for a full list and links to detailed descriptions of each table. From MariaDB 10.5, there are 80 Performance Schema tables, while until MariaDB 10.4, there are 52.
Activating the Performance Schema
The performance schema is disabled by default for performance reasons. You can check its current status by looking at the value of the performance_schema system variable.
SHOW VARIABLES LIKE 'performance_schema'; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | performance_schema | ON | +--------------------+-------+
The performance schema cannot be activated at runtime - it must be set when the server starts by adding the following line in your my.cnf
configuration file.
performance_schema=ON
Until MariaDB 10.4, all memory used by the Performance Schema is allocated at startup. From MariaDB 10.5, some memory is allocated dynamically, depending on load, number of connections, number of tables open etc.
Enabling the Performance Schema
You need to set up all consumers (starting collection of data) and instrumentations (what to collect):
UPDATE performance_schema.setup_consumers SET ENABLED = 'YES'; UPDATE performance_schema.setup_instruments SET ENABLED = 'YES', TIMED = 'YES';
You can decide what to enable/disable with WHERE NAME like "%what_to_enable"
; You can disable instrumentations by setting ENABLED
to "NO"
.
You can also do this in your my.cnf file. The following enables all instrumentation of all stages (computation units) in MariaDB:
[mysqld] performance_schema=ON performance-schema-instrument='stage/%=ON' performance-schema-consumer-events-stages-current=ON performance-schema-consumer-events-stages-history=ON performance-schema-consumer-events-stages-history-long=ON
Listing Performance Schema Variables
SHOW VARIABLES LIKE "perf%"; +--------------------------------------------------------+-------+ | Variable_name | Value | +--------------------------------------------------------+-------+ | performance_schema | ON | ... | performance_schema_users_size | 100 | +--------------------------------------------------------+-------+
See Performance Schema System Variables for a full list of available system variables.
Note that the "consumer" events are not shown on this list, as they are only available as options, not as system variables, and they can only be enabled at startup.
See Also
- Performance schema options
- SHOW ENGINE STATUS
- SHOW PROFILE
- ANALYZE STATEMENT
- Performance schema in MySQL 5.6. All things here should also work for MariaDB.
© 2021 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/performance-schema-overview/