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

MySQL 8.3 Reference Manual  /  ...  /  Performance Schema Wait Event Tables

29.12.4 性能模式等待事件表

性能模式记录等待事件,这些事件需要时间。在事件层次结构中,等待事件嵌套在阶段事件中,阶段事件嵌套在语句事件中,语句事件嵌套在事务事件中。

这些表存储等待事件:

以下部分描述等待事件表。还有汇总表,聚合等待事件信息;见 第 29.12.20.1 节,“等待事件汇总表”

要了解三个等待事件表之间的关系,请参阅 第 29.9 节,“性能模式当前和历史事件表”

配置等待事件收集

要控制是否收集等待事件,请设置相关仪器和消费者的状态:

  • The setup_instruments 表包含以 wait 开头的仪器名称。使用这些仪器来启用或禁用个别等待事件类的收集。

  • The setup_consumers 表包含与当前和历史等待事件表名称对应的消费者值。使用这些消费者来过滤等待事件的收集。

一些等待仪器默认启用;其他仪器默认禁用。例如:

mysql> SELECT NAME, ENABLED, TIMED
       FROM performance_schema.setup_instruments
       WHERE NAME LIKE 'wait/io/file/innodb%';
+-------------------------------------------------+---------+-------+
| NAME                                            | ENABLED | TIMED |
+-------------------------------------------------+---------+-------+
| wait/io/file/innodb/innodb_tablespace_open_file | YES     | YES   |
| wait/io/file/innodb/innodb_data_file            | YES     | YES   |
| wait/io/file/innodb/innodb_log_file             | YES     | YES   |
| wait/io/file/innodb/innodb_temp_file            | YES     | YES   |
| wait/io/file/innodb/innodb_arch_file            | YES     | YES   |
| wait/io/file/innodb/innodb_clone_file           | YES     | YES   |
+-------------------------------------------------+---------+-------+
mysql> SELECT NAME, ENABLED, TIMED
       FROM performance_schema.setup_instruments
       WHERE NAME LIKE 'wait/io/socket/%';
+----------------------------------------+---------+-------+
| NAME                                   | ENABLED | TIMED |
+----------------------------------------+---------+-------+
| wait/io/socket/sql/server_tcpip_socket | NO      | NO    |
| wait/io/socket/sql/server_unix_socket  | NO      | NO    |
| wait/io/socket/sql/client_connection   | NO      | NO    |
+----------------------------------------+---------+-------+

等待消费者默认禁用:

mysql> SELECT *
       FROM performance_schema.setup_consumers
       WHERE NAME LIKE 'events_waits%';
+---------------------------+---------+
| NAME                      | ENABLED |
+---------------------------+---------+
| events_waits_current      | NO      |
| events_waits_history      | NO      |
| events_waits_history_long | NO      |
+---------------------------+---------+

要在服务器启动时控制等待事件收集,请在 my.cnf 文件中添加以下行:

  • 启用:

    [mysqld]
    performance-schema-instrument='wait/%=ON'
    performance-schema-consumer-events-waits-current=ON
    performance-schema-consumer-events-waits-history=ON
    performance-schema-consumer-events-waits-history-long=ON
  • 禁用:

    [mysqld]
    performance-schema-instrument='wait/%=OFF'
    performance-schema-consumer-events-waits-current=OFF
    performance-schema-consumer-events-waits-history=OFF
    performance-schema-consumer-events-waits-history-long=OFF

要在运行时控制等待事件收集,请更新 setup_instrumentssetup_consumers 表:

  • 启用:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = 'YES', TIMED = 'YES'
    WHERE NAME LIKE 'wait/%';
    
    UPDATE performance_schema.setup_consumers
    SET ENABLED = 'YES'
    WHERE NAME LIKE 'events_waits%';
  • 禁用:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = 'NO', TIMED = 'NO'
    WHERE NAME LIKE 'wait/%';
    
    UPDATE performance_schema.setup_consumers
    SET ENABLED = 'NO'
    WHERE NAME LIKE 'events_waits%';

要仅收集特定的等待事件,请启用对应的等待仪器。要仅收集特定等待事件表的等待事件,请启用等待仪器,但仅启用对应表的等待消费者。

有关配置事件收集的更多信息,请参阅 第 29.3 节,“性能模式启动配置”第 29.4 节,“性能模式运行时配置”