25.12.4 性能架构 await 事件 table
性能架构工具会 await,这是需要时间的事件。在事件层次结构中,await 事件嵌套在阶段事件内,嵌套在语句事件内,嵌套在事务事件内。
这些 table 存储 await 事件:
-
events_waits_current:每个线程的当前 await 事件。
-
events_waits_history:每个线程已结束的最新 await 事件。
-
events_waits_history_long:全局(在所有线程中)结束的最新 await 事件。
以下各节描述了 await 事件 table。也有汇总 table,汇总有关 await 事件的信息。参见第 25.12.15.1 节,“await 事件摘要 table”。
有关三个 await 事件 table 之间的关系的更多信息,请参见第 25.9 节“当前和历史事件的性能架构 table”。
配置 await 事件收集
要控制是否收集 await 事件,请设置相关工具和使用者的状态:
-
setup_instrumentstable 包含名称以
wait
开头的乐器。使用这些工具可以启用或禁用单个 await 事件类的收集。 -
setup_consumerstable 包含名称与当前和历史 await 事件 table 名称相对应的使用者值。使用这些使用者来筛选 await 事件的集合。
默认情况下,某些 await 工具处于启用状态。其他人被禁用。例如:
mysql> SELECT * FROM performance_schema.setup_instruments
WHERE NAME LIKE 'wait/io/file/innodb%';
+--------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+--------------------------------------+---------+-------+
| 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 |
+--------------------------------------+---------+-------+
mysql> SELECT *
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 |
+----------------------------------------+---------+-------+
默认情况下,禁用 await 使用者:
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 |
+---------------------------+---------+
要控制服务器启动时的 await 事件收集,请在my.cnf
文件中使用以下行:
- Enable:
[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
- Disable:
[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
要在运行时控制 await 事件的收集,请更新setup_instruments和setup_consumerstable:
- Enable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME = 'wait/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'YES'
WHERE NAME LIKE 'events_waits%';
- Disable:
UPDATE performance_schema.setup_instruments
SET ENABLED = 'NO', TIMED = 'NO'
WHERE NAME = 'wait/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'NO'
WHERE NAME LIKE 'events_waits%';
要仅收集特定的 await 事件,请仅启用相应的 await 工具。要仅为特定的 await 事件 table 收集 await 事件,请启用 await 工具,但仅启用与所需 table 相对应的 await 使用者。
setup_timerstable 包含NAME
值为wait
的行,该行指示 await 事件计时的单位。默认单位是CYCLE
:
mysql> SELECT *
FROM performance_schema.setup_timers
WHERE NAME = 'wait';
+------+------------+
| NAME | TIMER_NAME |
+------+------------+
| wait | CYCLE |
+------+------------+
要更改计时单位,请修改TIMER_NAME
值:
UPDATE performance_schema.setup_timers
SET TIMER_NAME = 'NANOSECOND'
WHERE NAME = 'wait';
有关配置事件收集的其他信息,请参阅第 25.3 节“性能架构启动配置”和第 25.4 节“性能架构运行时配置”。