Documentation Home

22.4.7 消费者预过滤

setup_consumers表列出了可用的消费者类型以及哪些已启用:

mysql> SELECT * FROM performance_schema.setup_consumers;
+--------------------------------+---------+
| NAME                           | ENABLED |
+--------------------------------+---------+
| events_stages_current          | NO      |
| events_stages_history          | NO      |
| events_stages_history_long     | NO      |
| events_statements_current      | YES     |
| events_statements_history      | NO      |
| events_statements_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值设置为 YESNO

setup_consumers表的修改会立即影响监控。

如果禁用消费者,则服务器不会花时间维护该消费者的目的地。例如,如果您不关心历史事件信息,请禁用历史消费者:

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

表中的消费者设置 setup_consumers形成了从高到低的层次结构。以下原则适用:

  • 与消费者关联的目的地不会收到任何事件,除非性能模式检查消费者并且消费者已启用。

  • 一个消费者只有在它依赖的所有消费者(如果有的话)都被启用时才会被检查。

  • 如果一个消费者没有被选中,或者被选中但被禁用,那么依赖它的其他消费者也不会被选中。

  • 依赖消费者可能有自己的依赖消费者。

  • 如果事件不会发送到任何目的地,则性能模式不会产生它。

The following lists describe the available consumer values. For discussion of several representative consumer configurations and their effect on instrumentation, see Section 22.4.8, “Example Consumer Configurations”.

Global and Thread Consumers

  • 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 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

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, 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 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 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

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, 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 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 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

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_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 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 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.

Statement Digest Consumer

statements_digest消费者要求 global_instrumentation或 不YES检查。不依赖于语句事件消费者,因此您可以获取每个摘要的统计信息,而无需在 中收集统计信息 events_statements_current,这在开销方面是有利的。相反,您可以在 events_statements_current没有摘要的情况下获得详细的陈述(DIGESTDIGEST_TEXT列是 NULL)。

有关语句摘要的更多信息,请参阅 第 22.10 节,“性能模式语句摘要”