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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

29.4.8 示例消费者配置29.4.8 Example Consumer Configurations

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
Note

在 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_current消费者。如果这些events_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_xxx_current consumers are checked. If of these events_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).

无检测No Instrumentation

服务器配置状态:Server configuration state:

mysql> SELECT * FROM performance_schema.setup_consumers;
+---------------------------+---------+
| NAME                      | ENABLED |
+---------------------------+---------+
| global_instrumentation    | NO      |
...
+---------------------------+---------+

在此配置中,没有进行任何检测。In this configuration, nothing is instrumented.

已检查的设置元素:Setup elements checked:

维护的输出表:Output tables maintained:

  • 无None

仅全局检测Global Instrumentation Only

服务器配置状态: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:

相对于前一个配置,维护的额外输出表:Additional output tables maintained, relative to the preceding configuration:

仅全局和线程监控Global and Thread Instrumentation Only

服务器配置状态: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_current,其中 xxx 是 waits、stages、statements、transactionsTable setup_consumers, consumers events_xxx_current, where xxx is waits, stages, statements, transactions

  • 表 setup_actorsTable setup_actors

  • 列 threads.instrumentedColumn threads.instrumented

相对于前一个配置,维护的额外输出表:Additional output tables maintained, relative to the preceding configuration:

  • events_xxx_summary_by_yyy_by_event_name,其中 xxx 是 waits、stages、statements、transactions;yyy 是 thread、user、host、accountevents_xxx_summary_by_yyy_by_event_name, where xxx is waits, stages, statements, transactions; and yyy is thread, user, host, account

全局、线程和当前事件监控Global, Thread, and Current-Event Instrumentation

服务器配置状态: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_history,其中 xxx 可以是 waits、stages、statements、transactionsConsumers events_xxx_history, where xxx is waits, stages, statements, transactions

  • 使用者 events_xxx_history_long,其中 xxx 可以是 waits、stages、statements、transactionsConsumers events_xxx_history_long, where xxx is waits, stages, statements, transactions

相对于前一个配置,维护的额外输出表:Additional output tables maintained, relative to the preceding configuration:

  • events_xxx_current,其中 xxx 可以是 waits、stages、statements、transactionsevents_xxx_current, where xxx is waits, stages, statements, transactions

全局、线程、当前事件和事件历史监控Global, Thread, Current-Event, and Event-History instrumentation

前述配置不会收集事件历史,因为 events_xxx_history 和 events_xxx_history_long 消费者被禁用。这些消费者可以单独启用,也可以一起启用,以按线程、全局或两者收集事件历史。The preceding configuration collects no event history because the events_xxx_history and events_xxx_history_long consumers are disabled. Those consumers can be enabled separately or together to collect event history per thread, globally, or both.

此配置按线程收集事件历史,但不进行全局收集: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_history,其中 xxx 是 waits、stages、statements、transactionsevents_xxx_history, where xxx is waits, 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_long,其中 xxx 是 waits、stages、statements、transactionsevents_xxx_history_long, where xxx is waits, 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_history,其中 xxx 是 waits、stages、statements、transactionsevents_xxx_history, where xxx is waits, stages, statements, transactions

  • events_xxx_history_long,其中 xxx 是 waits、stages、statements、transactionsevents_xxx_history_long, where xxx is waits, stages, statements, transactions