文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

29.4.7 按消费者预过滤29.4.7 Pre-Filtering by Consumer

setup_consumers 表列出了可用的消费者类型及其启用状态:The setup_consumers table lists the available consumer types and which are enabled:

mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME                             | ENABLED |
+----------------------------------+---------+
| events_stages_current            | NO      |
| events_stages_history            | NO      |
| events_stages_history_long       | NO      |
| events_statements_cpu            | NO      |
| events_statements_current        | YES     |
| events_statements_history        | YES     |
| events_statements_history_long   | NO      |
| events_transactions_current      | YES     |
| events_transactions_history      | YES     |
| events_transactions_history_long | NO      |
| events_waits_current             | NO      |
| events_waits_history             | NO      |
| events_waits_history_long        | NO      |
| global_instrumentation           | YES     |
| thread_instrumentation           | YES     |
| statements_digest                | YES     |
+----------------------------------+---------+

修改 setup_consumers 表可以影响在消费者阶段的预过滤,并决定事件发送的目标。要启用或禁用某个消费者,请将其 ENABLED 值设置为 YES 或 NO。Modify the setup_consumers table to affect pre-filtering at the consumer stage and determine the destinations to which events are sent. To enable or disable a consumer, set its ENABLED value to YES or NO.

对 setup_consumers 表的修改会立即影响监控。Modifications to the setup_consumers table affect monitoring immediately.

如果您禁用一个消费者,服务器将不会花时间维护该消费者的目标。例如,如果您不关心历史事件信息,请禁用历史消费者:If you disable a consumer, the server does not spend time maintaining destinations for that consumer. For example, if you do not care about historical event information, disable the history consumers:

UPDATE performance_schema.setup_consumers
SET ENABLED = 'NO'
WHERE NAME LIKE '%history%';

setup_consumers 表中的消费者设置形成从上级到下级的层次结构。适用以下原则:The consumer settings in the setup_consumers table form a hierarchy from higher levels to lower. The following principles apply:

  • 与消费者关联的目标不会接收事件,除非性能模式检查了该消费者且该消费者已启用。Destinations associated with a consumer receive no events unless the Performance Schema checks the consumer and the consumer is enabled.

  • 只有在该消费者依赖的所有其他消费者(如果有)均已启用时,才会检查该消费者。A consumer is checked only if all consumers it depends on (if any) are enabled.

  • 如果一个消费者未被检查,或者已检查但被禁用,依赖它的其他消费者将不会被检查。If a consumer is not checked, or is checked but is disabled, other consumers that depend on it are not checked.

  • 依赖的消费者可能有它们自己的依赖消费者。Dependent consumers may have their own dependent consumers.

  • 如果事件不会被发送到任何目的地,性能模式将不会生成它。If an event would not be sent to any destination, the Performance Schema does not produce it.

下面的列表描述了可用的消费者值。关于几个典型消费者配置及其对测量的影响的讨论,请参见第 29.4.8 节,“示例消费者配置”。The following lists describe the available consumer values. For discussion of several representative consumer configurations and their effect on instrumentation, see Section 29.4.8, “Example Consumer Configurations”.

全局和线程消费者Global and Thread Consumers

  • global_instrumentation 是最高级别的消费者。如果 global_instrumentation 设置为 NO,则会禁用全局检测。所有其他设置都是较低级别的,不会被检查;它们设置为什么值都无关紧要。当前事件表或事件历史表中不会维护全局或每线程的信息,也不会收集单个事件。如果 global_instrumentation 设置为 YES,性能模式(Performance Schema)将维护全局状态信息,并且还会检查 thread_instrumentation 消费者。global_instrumentation is the highest level consumer. If global_instrumentation is NO, it disables global instrumentation. All other settings are lower level and are not checked; it does not matter what they are set to. No global or per thread information is maintained and no individual events are collected in the current-events or event-history tables. If global_instrumentation is YES, the Performance Schema maintains information for global states and also checks the thread_instrumentation consumer.

  • thread_instrumentation 仅在 global_instrumentation 为 YES 时才会被检查。否则,如果 thread_instrumentation 为 NO,它将禁用线程特定的检测,并且所有低级设置将被忽略。每个线程的信息不会被维护,也不会在当前事件或事件历史表中收集单独的事件。如果 thread_instrumentation 为 YES,性能模式会维护线程特定的信息,并且还会检查 events_xxx_current 消费者。thread_instrumentation is checked only if global_instrumentation is YES. Otherwise, if thread_instrumentation is NO, it disables thread-specific instrumentation and all lower-level settings are ignored. No information is maintained per thread and no individual events are collected in the current-events or event-history tables. If thread_instrumentation is YES, the Performance Schema maintains thread-specific information and also checks events_xxx_current consumers.

等待事件消费者Wait Event Consumers

这些消费者需要 global_instrumentation 和 thread_instrumentation 都为 YES,否则不会被检查。如果被检查,它们的行为如下:These consumers require both global_instrumentation and thread_instrumentation to be YES or they are not checked. If checked, they act as follows:

  • events_waits_current,如果为 NO,则禁用在 events_waits_current 表中对单个等待事件的收集。如果为 YES,则启用等待事件收集,Performance Schema 会检查 events_waits_history 和 events_waits_history_long 消费者。events_waits_current, if NO, disables collection of individual wait events in the events_waits_current table. If YES, it enables wait event collection and the Performance Schema checks the events_waits_history and events_waits_history_long consumers.

  • events_waits_history 如果 event_waits_current 为 NO 则不会被检查。否则,events_waits_history 的 NO 或 YES 值会禁用或启用在 events_waits_history 表中收集等待事件。events_waits_history is not checked if event_waits_current is NO. Otherwise, an events_waits_history value of NO or YES disables or enables collection of wait events in the events_waits_history table.

  • events_waits_history_long 不会检查 event_waits_current 是否为 NO。否则,events_waits_history_long 的值为 NO 或 YES 会禁用或启用在 events_waits_history_long 表中等待事件的收集。events_waits_history_long is not checked if event_waits_current is NO. Otherwise, an events_waits_history_long value of NO or YES disables or enables collection of wait events in the events_waits_history_long table.

阶段事件消费者Stage Event Consumers

这些消费者需要 global_instrumentation 和 thread_instrumentation 都为 YES,否则不会被检查。如果被检查,它们的行为如下:These consumers require both global_instrumentation and thread_instrumentation to be YES or they are not checked. If checked, they act as follows:

  • events_stages_current,如果为 NO,则禁用在 events_stages_current 表中收集单独阶段事件。 如果为 YES,则启用阶段事件收集,并且性能模式会检查 events_stages_history 和 events_stages_history_long 消费者。events_stages_current, if NO, disables collection of individual stage events in the events_stages_current table. If YES, it enables stage event collection and the Performance Schema checks the events_stages_history and events_stages_history_long consumers.

  • events_stages_history 如果 event_stages_current 为 NO 则不会被检查。否则,events_stages_history 的 NO 或 YES 值会禁用或启用在 events_stages_history 表中收集阶段事件。events_stages_history is not checked if event_stages_current is NO. Otherwise, an events_stages_history value of NO or YES disables or enables collection of stage events in the events_stages_history table.

  • events_stages_history_long 不会被检查,如果 event_stages_current 是 NO。否则,一个 events_stages_history_long 值为 NO 或 YES 会禁用或启用在 events_stages_history_long 表中收集阶段事件。events_stages_history_long is not checked if event_stages_current is NO. Otherwise, an events_stages_history_long value of NO or YES disables or enables collection of stage events in the events_stages_history_long table.

语句事件消费者Statement Event Consumers

这些消费者需要 global_instrumentation 和 thread_instrumentation 都为 YES,否则不会被检查。如果被检查,它们的行为如下:These consumers require both global_instrumentation and thread_instrumentation to be YES or they are not checked. If checked, they act as follows:

  • events_statements_cpu,如果为 NO,会禁用对 CPU_TIME 的测量。如果为 YES,并且启用了实例化并进行计时,则会测量 CPU_TIME。events_statements_cpu, if NO, disables measurement of CPU_TIME. If YES, and the instrumentation is enabled and timed, CPU_TIME is measured.

  • events_statements_current,如果为 NO,则禁用在 events_statements_current 表中收集单独的语句事件。如果为 YES,则启用语句事件收集,并且性能模式会检查 events_statements_history 和 events_statements_history_long 消费者。events_statements_current, if NO, disables collection of individual statement events in the events_statements_current table. If YES, it enables statement event collection and the Performance Schema checks the events_statements_history and events_statements_history_long consumers.

  • events_statements_history 如果 events_statements_current 为 NO 则不会被检查。否则,events_statements_history 的 NO 或 YES 值会禁用或启用在 events_statements_history 表中收集语句事件。events_statements_history is not checked if events_statements_current is NO. Otherwise, an events_statements_history value of NO or YES disables or enables collection of statement events in the events_statements_history table.

  • events_statements_history_long 在 events_statements_current 为 NO 时不会被检查。否则,events_statements_history_long 的 NO 或 YES 值会在 events_statements_history_long 表中禁用或启用语句事件的收集。events_statements_history_long is not checked if events_statements_current is NO. Otherwise, an events_statements_history_long value of NO or YES disables or enables collection of statement events in the events_statements_history_long table.

事务事件消费者Transaction Event Consumers

这些消费者需要 global_instrumentation 和 thread_instrumentation 都为 YES,否则不会被检查。如果被检查,它们的行为如下:These consumers require both global_instrumentation and thread_instrumentation to be YES or they are not checked. If checked, they act as follows:

  • events_transactions_current,如果为NO,则禁用在events_transactions_current表中收集单个事务事件。如果为YES,则启用事务事件收集,并且性能模式会检查events_transactions_history和events_transactions_history_long消费者。events_transactions_current, if NO, disables collection of individual transaction events in the events_transactions_current table. If YES, it enables transaction event collection and the Performance Schema checks the events_transactions_history and events_transactions_history_long consumers.

  • events_transactions_history 在 events_transactions_current 为 NO 时不会被检查。否则,events_transactions_history 的 NO 或 YES 值将禁用或启用在 events_transactions_history 表中收集事务事件。events_transactions_history is not checked if events_transactions_current is NO. Otherwise, an events_transactions_history value of NO or YES disables or enables collection of transaction events in the events_transactions_history table.

  • events_transactions_history_long 不会被检查,如果 events_transactions_current 是 NO。否则,events_transactions_history_long 的 NO 或 YES 值会禁用或启用 events_transactions_history_long 表中的事务事件收集。events_transactions_history_long is not checked if events_transactions_current is NO. Otherwise, an events_transactions_history_long value of NO or YES disables or enables collection of transaction events in the events_transactions_history_long table.

语句摘要消费者Statement Digest Consumer

statements_digest 消费者要求 global_instrumentation 为 YES,否则不会进行检查。它不依赖于语句事件消费者,因此您可以获取每个摘要的统计信息,而无需在 events_statements_current 中收集统计信息,这在开销方面具有优势。相反,您可以在 events_statements_current 中获得详细语句信息,而不使用摘要(在这种情况下,DIGEST 和 DIGEST_TEXT 列为 NULL)。The statements_digest consumer requires global_instrumentation to be YES or it is not checked. There is no dependency on the statement event consumers, so you can obtain statistics per digest without having to collect statistics in events_statements_current, which is advantageous in terms of overhead. Conversely, you can get detailed statements in events_statements_current without digests (the DIGEST and DIGEST_TEXT columns are NULL in this case).

有关语句摘要的更多信息,请参见 第 29.10 节,“Performance Schema 语句摘要与采样”。For more information about statement digesting, see Section 29.10, “Performance Schema Statement Digests and Sampling”.