Documentation Home
MySQL 8.3 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 294.0Kb
Man Pages (Zip) - 409.0Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb
Excerpts from this Manual

29.4.8 示例消费者配置

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

配置描述按照增加的功能和开销顺序出现。如果您不需要启用较低级别设置所提供的信息,请禁用它们,以便 Performance Schema 执行较少的代码,并且需要浏览的信息较少。

The 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

在消费者层次结构中,等待、阶段、语句和事务的消费者都在同一级别。这与事件嵌套层次结构不同,wait 事件嵌套在阶段事件中,阶段事件嵌套在语句事件中,语句事件嵌套在事务事件中。

如果给定的消费者设置为 NO,Performance Schema 将禁用与消费者关联的仪器并忽略所有较低级别的设置。如果给定的设置为 YES,Performance Schema 将启用与其关联的仪器并检查下一个最低级别的设置。有关每个消费者的规则描述,请参见 第 29.4.7 节,“按消费者预过滤”

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

每个以下配置描述都指出了 Performance 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      |
...
+---------------------------+---------+

在此配置中,仅全局状态被仪器。每线程仪器被禁用。

相比前一个配置,检查的附加设置元素:

相比前一个配置,额外的输出表格:

全局和线程 Instrumentation Only

服务器配置状态:

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

在这个配置中,instrumentation 是在全局和每个线程中维护的。当前事件表和事件历史表中没有收集单个事件。

相比前一个配置,额外的 setup 元素被检查:

  • setup_consumers, 消费者 events_xxx_current, 其中 xxxwaits, stages, statements, transactions

  • setup_actors

  • threads.instrumented

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

  • events_xxx_summary_by_yyy_by_event_name, 其中 xxxwaits, stages, statements, transactions; 和 yyythread, user, host, account

全局、线程和当前事件仪表

服务器配置状态:

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_history, 其中 xxxwaits, stages, statements, transactions

  • 消费者 events_xxx_history_long, 其中 xxxwaits, stages, statements, transactions

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

  • events_xxx_current, 其中 xxxwaits, stages, statements, transactions

全局、线程、当前事件和事件历史仪表

前一个配置不收集事件历史,因为 events_xxx_historyevents_xxx_history_long 消费者被禁用。这些消费者可以单独或一起启用以收集事件历史。

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

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_history, 其中 xxxwaits, stages, statements, transactions

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

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_long, 其中 xxxwaits, stages, statements, transactions

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

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_history, 其中 xxxwaits, stages, statements, transactions

  • events_xxx_history_long, 其中 xxxwaits, stages, statements, transactions