Documentation Home
MySQL 8.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.8Mb
PDF (A4) - 39.9Mb
Man Pages (TGZ) - 257.9Kb
Man Pages (Zip) - 364.9Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


29.4.8 消费者配置示例

setup_consumers 表中,消费者设置形成了一个层级结构,从高层次到低层次。以下讨论描述了如何工作的消费者,展示了逐步从高到低启用的特定配置及其效果。显示的消费者值是代表性的。这里描述的通用原则也适用于可能可用的其他消费者值。

配置描述按功能增加和开销排序。如果您不需要通过启用较低级别设置提供的信息,请禁用它们,以便性能_schema 在您的 behalf 执行更少的代码,并且有更少的信息要筛选。

setup_consumers 表中包含以下层级结构的值:

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

在消费者层级中,等待、阶段、语句和事务的消费者都位于同一层次。这与事件嵌套层级不同,其中等待事件嵌套在阶段事件中,后者嵌套在语句事件中,最后嵌套在事务事件中。

如果给定的消费者设置为 NO,性能_schema 禁用与之关联的仪器,并忽略所有较低级别的设置。如果一个设置为 YES,性能_schema 启用与其关联的仪器,并检查下一层次的设置。对于每个消费者的规则描述,请参阅第 29.4.7 节,“按消费者预过滤”

例如,如果 global_instrumentation 启用了,thread_instrumentation 将被检查。如果 thread_instrumentation 启用了,那么 events_xxx_current 消费者将被检查。若这些 events_waits_current 启用了,events_waits_historyevents_waits_history_long 将被检查。

以下每个配置描述指示性能_schema 检查的设置元素以及它维护的输出表(即,它收集哪些表的信息)。

服务器配置状态:

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

在这个配置中,没有任何内容被仪器化。

检查的设置元素:

维护的输出表:

服务器配置状态:

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

在这个配置中,只有全局状态的仪器化被维护。线程级别的仪器化被禁用。

相对于前一个配置,额外检查的设置元素:

相对于前一个配置,额外维护的输出表:

服务器配置状态:

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

在这个配置中,性能监控是全局性的和按线程的。当前事件表和历史事件表中不收集任何个别事件。

相对于前一个配置,额外检查了以下设置元素:

  • setup_consumers,消费者events_xxx_current,其中xxxwaitsstagesstatementstransactions

  • setup_actors

  • threads.instrumented

相对于前一个配置,额外维护的输出表格:

  • events_xxx_summary_by_yyy_by_event_name,其中xxxwaitsstagesstatementstransactions;以及yyythreaduserhostaccount

服务器配置状态:

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

在这个配置中,仪表盘是全局和每个线程维护的。单个事件被收集到当前-事件表中,但不在事件-历史表中。

相对于前一个配置,额外设置元素检查了:

  • 消费者events_xxx_historyxxxwaitsstagesstatementstransactions

  • 消费者events_xxx_history_长xxxwaitsstagesstatementstransactions

相对于前一个配置,额外维护的输出表:

  • events_xxx_currentxxxwaitsstagesstatementstransactions

前面的配置不收集事件历史,因为events_xxx_historyevents_xxx_history_长消费者被禁用。这些消费者可以单独或一起启用,以收集每个线程、全局或两者的事件历史。

这个配置收集的是每个线程的事件历史,但不是全局的:

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

为此配置维护的事件历史表:

  • events_xxx_historyxxxwaitsstagesstatementstransactions

这个配置收集的是全局的事件历史,但不是每个线程的:

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

为此配置维护的事件历史表:

  • events_xxx_history_长xxxwaitsstagesstatementstransactions

这个配置收集的是每个线程和全局的事件历史:

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

为此配置维护的事件历史表:

  • events_xxx_historyxxxwaitsstagesstatementstransactions

  • events_xxx_history_长xxxwaitsstagesstatementstransactions