内存
要跟踪使用内存的内容,请添加到 MySQL 配置文件:
performance_schema_instrument = memory/%=COUNTED
开销通常很小,但对于连接/断开连接,在最坏的情况下开销会增加到 6% 左右。
on It Road.com
交易
我们可以使用(在 MySQL 配置文件中)启用事务监控:
performance_schema_instrument = transaction=ON performance_schema_consumer_events_transactions_current = ON
这将启用对当前事务的监视。
如果要保留每个连接的最后 10 个事务的默认值,则添加包括:
performance_schema_consumer_events_transactions_history = ON
预计这种开销非常小。
在这篇文章中,我们将看到如何配置 Performance Schema 并避免它成为性能瓶颈。
默认设置是一个很好的起点。
这些已经过广泛测试,以确保在绝大多数情况下,它们不会造成严重的开销。
值得考虑启用一些另外的消费者和工具。
虽然下面的建议通常只会导致很小的开销或者没有开销,但值得测试另外仪器和消费者的开销是否可以接受,并且在进行更改之前有一个监控基线是值得的,以便在更改时清楚更改是什么配置。
要启用以下所有建议,请使用(需要 MySQL 5.7 或者更高版本):
[mysqld] performance_schema_instrument = transaction=ON performance_schema_instrument = wait/lock/metadata/sql/mdl=ON performance_schema_instrument = memory/%=COUNTED performance_schema_consumer_events_statements_history_long = ON performance_schema_consumer_events_transactions_current = ON performance_schema_consumer_events_transactions_history = ON All butperformance_schema_consumer_events_statements_history_long are enabled by default in MySQL 8.0.
MySQL 服务器 5.7 及更高版本
在 MySQL 5.7 中,值得考虑启用以下部分中讨论的使用者和工具。
元数据锁(Metadata Lock)
要启用元数据锁的监控,请添加到 MySQL 配置文件:
performance_schema_instrument = wait/lock/metadata/sql/mdl=ON
预计开销很小。
MySQL 服务器 5.6 及更高版本
如果我们在 MySQL Enterprise Monitor 中使用查询分析器并想要示例查询并解释使用性能模式收集的查询的计划,则需要保留最近执行的查询的历史记录:
performance_schema_consumer_events_statements_history_long = ON
这将保留(默认情况下)最近执行的 10000 条语句。
开销通常很小。
日期:2020-09-17 00:11:13 来源:oir作者:oir