setup_consumers 表中的消费者设置形成了从高层到低层的层次结构。下面的讨论描述了消费者的工作方式,展示了具体配置及其效果,随着从高到低逐步启用消费者设置。所示的消费者值是具有代表性的。这里描述的一般原则适用于可能提供的其他消费者值。The consumer settings in the
setup_consumers table form a
hierarchy from higher levels to lower. The following discussion
describes how consumers work, showing specific configurations
and their effects as consumer settings are enabled progressively
from high to low. The consumer values shown are representative.
The general principles described here apply to other consumer
values that may be available.
配置描述按功能和开销递增的顺序给出。如果你不需要通过启用低层次设置提供的信息,请禁用它们,这样 Performance Schema 执行的代码更少,你也需要处理的信息就更少。The configuration descriptions occur in order of increasing functionality and overhead. If you do not need the information provided by enabling lower-level settings, disable them so that the Performance Schema executes less code on your behalf and there is less information to sift through.
setup_consumers 表包含以下值的层次结构:The setup_consumers table contains
the following hierarchy of values:
global_instrumentation
thread_instrumentation
events_waits_current
events_waits_history
events_waits_history_long
events_stages_current
events_stages_history
events_stages_history_long
events_statements_current
events_statements_history
events_statements_history_long
events_transactions_current
events_transactions_history
events_transactions_history_long
statements_digest
在 consumer 层次结构中,等待(waits)、阶段(stages)、语句(statements)和事务(transactions)的 consumer 都在同一级别。这与事件嵌套层次结构不同,在事件嵌套层次结构中,等待事件嵌套在阶段事件中,阶段事件嵌套在语句事件中,语句事件嵌套在事务事件中。In the consumer hierarchy, the consumers for waits, stages, statements, and transactions are all at the same level. This differs from the event nesting hierarchy, for which wait events nest within stage events, which nest within statement events, which nest within transaction events.
如果给定的消费者设置为 NO,性能模式会禁用与该消费者相关的测量仪表,并忽略所有较低级别的设置。如果给定的设置为 YES,性能模式会启用与其相关的测量仪表,并检查下一个最低级别的设置。有关每个消费者规则的描述,请参阅 第 29.4.7 节,“按消费者预过滤”。If a given consumer setting is NO, the
Performance Schema disables the instrumentation associated with
the consumer and ignores all lower-level settings. If a given
setting is YES, the Performance Schema
enables the instrumentation associated with it and checks the
settings at the next lowest level. For a description of the
rules for each consumer, see
Section 29.4.7, “Pre-Filtering by Consumer”.
例如,如果启用了global_instrumentation,将会检查thread_instrumentation。如果启用了thread_instrumentation,将会检查events_消费者。如果这些xxx_currentevents_waits_current启用,则会检查events_waits_history和events_waits_history_long。For example, if global_instrumentation is
enabled, thread_instrumentation is checked.
If thread_instrumentation is enabled, the
events_
consumers are checked. If of these
xxx_currentevents_waits_current is enabled,
events_waits_history and
events_waits_history_long are checked.
以下每个配置说明都指示了性能模式检查哪些设置元素,以及它维护哪些输出表(也就是说,它为哪些表收集信息)。Each of the following configuration descriptions indicates which setup elements the Performance Schema checks and which output tables it maintains (that is, for which tables it collects information).
服务器配置状态:Server configuration state:
mysql> SELECT * FROM performance_schema.setup_consumers;
+---------------------------+---------+
| NAME | ENABLED |
+---------------------------+---------+
| global_instrumentation | NO |
...
+---------------------------+---------+
在此配置中,没有进行任何检测。In this configuration, nothing is instrumented.
已检查的设置元素:Setup elements checked:
表
setup_consumers,消费者global_instrumentationTablesetup_consumers, consumerglobal_instrumentation
维护的输出表:Output tables maintained:
无None
服务器配置状态:Server configuration state:
mysql> SELECT * FROM performance_schema.setup_consumers;
+---------------------------+---------+
| NAME | ENABLED |
+---------------------------+---------+
| global_instrumentation | YES |
| thread_instrumentation | NO |
...
+---------------------------+---------+
在此配置中,监控仅针对全局状态进行维护。每线程监控已禁用。In this configuration, instrumentation is maintained only for global states. Per-thread instrumentation is disabled.
相对于前一个配置,检查了额外的设置元素:Additional setup elements checked, relative to the preceding configuration:
表
setup_consumers,消费者thread_instrumentationTablesetup_consumers, consumerthread_instrumentation表
setup_objectsTablesetup_objects
相对于前一个配置,维护的额外输出表:Additional output tables maintained, relative to the preceding configuration:
objects_summary_global_by_typeobjects_summary_global_by_typememory_summary_global_by_event_namememory_summary_global_by_event_nametable_lock_waits_summary_by_tabletable_lock_waits_summary_by_tabletable_io_waits_summary_by_index_usagetable_io_waits_summary_by_index_usagetable_io_waits_summary_by_tabletable_io_waits_summary_by_tableevents_waits_summary_by_instanceevents_waits_summary_by_instanceevents_waits_summary_global_by_event_nameevents_waits_summary_global_by_event_nameevents_stages_summary_global_by_event_nameevents_stages_summary_global_by_event_nameevents_statements_summary_global_by_event_nameevents_statements_summary_global_by_event_nameevents_transactions_summary_global_by_event_nameevents_transactions_summary_global_by_event_name
服务器配置状态:Server configuration state:
mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| global_instrumentation | YES |
| thread_instrumentation | YES |
| events_waits_current | NO |
...
| events_stages_current | NO |
...
| events_statements_current | NO |
...
| events_transactions_current | NO |
...
+----------------------------------+---------+
在此配置中,监控按全局和每个线程维护。当前事件表或事件历史表中不会收集单个事件。In this configuration, instrumentation is maintained globally and per thread. No individual events are collected in the current-events or event-history tables.
相对于前一个配置,检查了额外的设置元素:Additional setup elements checked, relative to the preceding configuration:
表
setup_consumers,消费者events_,其中xxx_currentxxx是waits、stages、statements、transactionsTablesetup_consumers, consumersevents_, wherexxx_currentxxxiswaits,stages,statements,transactions表
setup_actorsTablesetup_actors列
threads.instrumentedColumnthreads.instrumented
相对于前一个配置,维护的额外输出表:Additional output tables maintained, relative to the preceding configuration:
events_,其中xxx_summary_by_yyy_by_event_namexxx是waits、stages、statements、transactions;yyy是thread、user、host、accountevents_, wherexxx_summary_by_yyy_by_event_namexxxiswaits,stages,statements,transactions; andyyyisthread,user,host,account
服务器配置状态:Server configuration state:
mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| global_instrumentation | YES |
| thread_instrumentation | YES |
| events_waits_current | YES |
| events_waits_history | NO |
| events_waits_history_long | NO |
| events_stages_current | YES |
| events_stages_history | NO |
| events_stages_history_long | NO |
| events_statements_current | YES |
| events_statements_history | NO |
| events_statements_history_long | NO |
| events_transactions_current | YES |
| events_transactions_history | NO |
| events_transactions_history_long | NO |
...
+----------------------------------+---------+
在此配置中,监控信息在全局和每个线程中维护。单个事件会被收集到当前事件表中,但不会收集到事件历史表中。In this configuration, instrumentation is maintained globally and per thread. Individual events are collected in the current-events table, but not in the event-history tables.
相对于前一个配置,检查了额外的设置元素:Additional setup elements checked, relative to the preceding configuration:
使用者
events_,其中xxx_historyxxx可以是waits、stages、statements、transactionsConsumersevents_, wherexxx_historyxxxiswaits,stages,statements,transactions使用者
events_,其中xxx_history_longxxx可以是waits、stages、statements、transactionsConsumersevents_, wherexxx_history_longxxxiswaits,stages,statements,transactions
相对于前一个配置,维护的额外输出表:Additional output tables maintained, relative to the preceding configuration:
events_,其中xxx_currentxxx可以是waits、stages、statements、transactionsevents_, wherexxx_currentxxxiswaits,stages,statements,transactions
前述配置不会收集事件历史,因为 events_ 和 xxx_historyevents_ 消费者被禁用。这些消费者可以单独启用,也可以一起启用,以按线程、全局或两者收集事件历史。The preceding configuration collects no event history because
the
xxx_history_longevents_
and
xxx_historyevents_
consumers are disabled. Those consumers can be enabled
separately or together to collect event history per thread,
globally, or both.xxx_history_long
此配置按线程收集事件历史,但不进行全局收集:This configuration collects event history per thread, but not globally:
mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| global_instrumentation | YES |
| thread_instrumentation | YES |
| events_waits_current | YES |
| events_waits_history | YES |
| events_waits_history_long | NO |
| events_stages_current | YES |
| events_stages_history | YES |
| events_stages_history_long | 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 |
...
+----------------------------------+---------+
此配置维护的事件历史表:Event-history tables maintained for this configuration:
events_,其中xxx_historyxxx是waits、stages、statements、transactionsevents_, wherexxx_historyxxxiswaits,stages,statements,transactions
此配置全局收集事件历史记录,但不按线程收集:This configuration collects event history globally, but not per thread:
mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| global_instrumentation | YES |
| thread_instrumentation | YES |
| events_waits_current | YES |
| events_waits_history | NO |
| events_waits_history_long | YES |
| events_stages_current | YES |
| events_stages_history | NO |
| events_stages_history_long | YES |
| events_statements_current | YES |
| events_statements_history | NO |
| events_statements_history_long | YES |
| events_transactions_current | YES |
| events_transactions_history | NO |
| events_transactions_history_long | YES |
...
+----------------------------------+---------+
此配置维护的事件历史表:Event-history tables maintained for this configuration:
events_,其中xxx_history_longxxx是waits、stages、statements、transactionsevents_, wherexxx_history_longxxxiswaits,stages,statements,transactions
此配置按线程和全局收集事件历史记录:This configuration collects event history per thread and globally:
mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| global_instrumentation | YES |
| thread_instrumentation | YES |
| events_waits_current | YES |
| events_waits_history | YES |
| events_waits_history_long | YES |
| events_stages_current | YES |
| events_stages_history | YES |
| events_stages_history_long | YES |
| events_statements_current | YES |
| events_statements_history | YES |
| events_statements_history_long | YES |
| events_transactions_current | YES |
| events_transactions_history | YES |
| events_transactions_history_long | YES |
...
+----------------------------------+---------+
此配置维护的事件历史表:Event-history tables maintained for this configuration:
events_,其中xxx_historyxxx是waits、stages、statements、transactionsevents_, wherexxx_historyxxxiswaits,stages,statements,transactionsevents_,其中xxx_history_longxxx是waits、stages、statements、transactionsevents_, wherexxx_history_longxxxiswaits,stages,statements,transactions