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_instrumentation是最高级别的消费者。如果global_instrumentation设置为NO,则会禁用全局检测。所有其他设置都是较低级别的,不会被检查;它们设置为什么值都无关紧要。当前事件表或事件历史表中不会维护全局或每线程的信息,也不会收集单个事件。如果global_instrumentation设置为YES,性能模式(Performance Schema)将维护全局状态信息,并且还会检查thread_instrumentation消费者。global_instrumentationis the highest level consumer. Ifglobal_instrumentationisNO, 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. Ifglobal_instrumentationisYES, the Performance Schema maintains information for global states and also checks thethread_instrumentationconsumer.thread_instrumentation仅在global_instrumentation为YES时才会被检查。否则,如果thread_instrumentation为NO,它将禁用线程特定的检测,并且所有低级设置将被忽略。每个线程的信息不会被维护,也不会在当前事件或事件历史表中收集单独的事件。如果thread_instrumentation为YES,性能模式会维护线程特定的信息,并且还会检查events_消费者。xxx_currentthread_instrumentationis checked only ifglobal_instrumentationisYES. Otherwise, ifthread_instrumentationisNO, 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. Ifthread_instrumentationisYES, the Performance Schema maintains thread-specific information and also checksevents_consumers.xxx_current
这些消费者需要 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, ifNO, disables collection of individual wait events in theevents_waits_currenttable. IfYES, it enables wait event collection and the Performance Schema checks theevents_waits_historyandevents_waits_history_longconsumers.events_waits_history如果event_waits_current为NO则不会被检查。否则,events_waits_history的NO或YES值会禁用或启用在events_waits_history表中收集等待事件。events_waits_historyis not checked ifevent_waits_currentisNO. Otherwise, anevents_waits_historyvalue ofNOorYESdisables or enables collection of wait events in theevents_waits_historytable.events_waits_history_long不会检查event_waits_current是否为NO。否则,events_waits_history_long的值为NO或YES会禁用或启用在events_waits_history_long表中等待事件的收集。events_waits_history_longis not checked ifevent_waits_currentisNO. Otherwise, anevents_waits_history_longvalue ofNOorYESdisables or enables collection of wait events in theevents_waits_history_longtable.
这些消费者需要 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, ifNO, disables collection of individual stage events in theevents_stages_currenttable. IfYES, it enables stage event collection and the Performance Schema checks theevents_stages_historyandevents_stages_history_longconsumers.events_stages_history如果event_stages_current为NO则不会被检查。否则,events_stages_history的NO或YES值会禁用或启用在events_stages_history表中收集阶段事件。events_stages_historyis not checked ifevent_stages_currentisNO. Otherwise, anevents_stages_historyvalue ofNOorYESdisables or enables collection of stage events in theevents_stages_historytable.events_stages_history_long不会被检查,如果event_stages_current是NO。否则,一个events_stages_history_long值为NO或YES会禁用或启用在events_stages_history_long表中收集阶段事件。events_stages_history_longis not checked ifevent_stages_currentisNO. Otherwise, anevents_stages_history_longvalue ofNOorYESdisables or enables collection of stage events in theevents_stages_history_longtable.
这些消费者需要 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, ifNO, disables measurement ofCPU_TIME. IfYES, and the instrumentation is enabled and timed,CPU_TIMEis measured.events_statements_current,如果为NO,则禁用在events_statements_current表中收集单独的语句事件。如果为YES,则启用语句事件收集,并且性能模式会检查events_statements_history和events_statements_history_long消费者。events_statements_current, ifNO, disables collection of individual statement events in theevents_statements_currenttable. IfYES, it enables statement event collection and the Performance Schema checks theevents_statements_historyandevents_statements_history_longconsumers.events_statements_history如果events_statements_current为NO则不会被检查。否则,events_statements_history的NO或YES值会禁用或启用在events_statements_history表中收集语句事件。events_statements_historyis not checked ifevents_statements_currentisNO. Otherwise, anevents_statements_historyvalue ofNOorYESdisables or enables collection of statement events in theevents_statements_historytable.events_statements_history_long在events_statements_current为NO时不会被检查。否则,events_statements_history_long的NO或YES值会在events_statements_history_long表中禁用或启用语句事件的收集。events_statements_history_longis not checked ifevents_statements_currentisNO. Otherwise, anevents_statements_history_longvalue ofNOorYESdisables or enables collection of statement events in theevents_statements_history_longtable.
这些消费者需要 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, ifNO, disables collection of individual transaction events in theevents_transactions_currenttable. IfYES, it enables transaction event collection and the Performance Schema checks theevents_transactions_historyandevents_transactions_history_longconsumers.events_transactions_history在events_transactions_current为NO时不会被检查。否则,events_transactions_history的NO或YES值将禁用或启用在events_transactions_history表中收集事务事件。events_transactions_historyis not checked ifevents_transactions_currentisNO. Otherwise, anevents_transactions_historyvalue ofNOorYESdisables or enables collection of transaction events in theevents_transactions_historytable.events_transactions_history_long不会被检查,如果events_transactions_current是NO。否则,events_transactions_history_long的NO或YES值会禁用或启用events_transactions_history_long表中的事务事件收集。events_transactions_history_longis not checked ifevents_transactions_currentisNO. Otherwise, anevents_transactions_history_longvalue ofNOorYESdisables or enables collection of transaction events in theevents_transactions_history_longtable.
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”.