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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

29.4.4 按检测对象的预过滤29.4.4 Pre-Filtering by Instrument

setup_instruments 表列出了可用的检测对象:The setup_instruments table lists the available instruments:

mysql> SELECT NAME, ENABLED, TIMED
       FROM performance_schema.setup_instruments;
+---------------------------------------------------+---------+-------+
| NAME                                              | ENABLED | TIMED |
+---------------------------------------------------+---------+-------+
...
| stage/sql/end                                     | NO      | NO    |
| stage/sql/executing                               | NO      | NO    |
| stage/sql/init                                    | NO      | NO    |
| stage/sql/insert                                  | NO      | NO    |
...
| statement/sql/load                                | YES     | YES   |
| statement/sql/grant                               | YES     | YES   |
| statement/sql/check                               | YES     | YES   |
| statement/sql/flush                               | YES     | YES   |
...
| wait/synch/mutex/sql/LOCK_global_read_lock        | YES     | YES   |
| wait/synch/mutex/sql/LOCK_global_system_variables | YES     | YES   |
| wait/synch/mutex/sql/LOCK_lock_db                 | YES     | YES   |
| wait/synch/mutex/sql/LOCK_manager                 | YES     | YES   |
...
| wait/synch/rwlock/sql/LOCK_grant                  | YES     | YES   |
| wait/synch/rwlock/sql/LOGGER::LOCK_logger         | YES     | YES   |
| wait/synch/rwlock/sql/LOCK_sys_init_connect       | YES     | YES   |
| wait/synch/rwlock/sql/LOCK_sys_init_slave         | YES     | YES   |
...
| wait/io/file/sql/binlog                           | YES     | YES   |
| wait/io/file/sql/binlog_index                     | YES     | YES   |
| wait/io/file/sql/casetest                         | YES     | YES   |
| wait/io/file/sql/dbopt                            | YES     | YES   |
...

要控制仪器是否启用,请将其 ENABLED 列设置为 YES 或 NO。要配置是否为已启用的仪器收集时间信息,请将其 TIMED 值设置为 YES 或 NO。设置 TIMED 列会影响性能模式表的内容,如 第 29.4.1 节,“性能模式事件定时” 所述。To control whether an instrument is enabled, set its ENABLED column to YES or NO. To configure whether to collect timing information for an enabled instrument, set its TIMED value to YES or NO. Setting the TIMED column affects Performance Schema table contents as described in Section 29.4.1, “Performance Schema Event Timing”.

对大多数 setup_instruments 行的修改会立即影响监控。对于某些仪器,修改仅在服务器启动时生效;在运行时更改它们没有效果。这主要影响服务器中的互斥锁、条件变量和读写锁,尽管可能还有其他仪器也适用这种情况。Modifications to most setup_instruments rows affect monitoring immediately. For some instruments, modifications are effective only at server startup; changing them at runtime has no effect. This affects primarily mutexes, conditions, and rwlocks in the server, although there may be other instruments for which this is true.

setup_instruments 表提供了对事件生成控制的最基本形式。为了根据被监控对象或线程的类型进一步细化事件生成,可以使用其他表,如第 29.4.3 节,“事件预过滤”中所述。The setup_instruments table provides the most basic form of control over event production. To further refine event production based on the type of object or thread being monitored, other tables may be used as described in Section 29.4.3, “Event Pre-Filtering”.

以下示例展示了对 setup_instruments 表可能进行的操作。这些更改与其他预过滤操作一样,会影响所有用户。其中一些查询使用了 LIKE 运算符和模式匹配来匹配仪器名称。有关指定模式以选择仪器的更多信息,请参阅 第 29.4.9 节,“为过滤操作命名仪器或消费者”。The following examples demonstrate possible operations on the setup_instruments table. These changes, like other pre-filtering operations, affect all users. Some of these queries use the LIKE operator and a pattern match instrument names. For additional information about specifying patterns to select instruments, see Section 29.4.9, “Naming Instruments or Consumers for Filtering Operations”.

  • 禁用所有仪器:Disable all instruments:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = 'NO';
    

    现在不收集任何事件。Now no events are collected.

  • 禁用所有文件仪器,将它们添加到当前已禁用的仪器集合中:Disable all file instruments, adding them to the current set of disabled instruments:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = 'NO'
    WHERE NAME LIKE 'wait/io/file/%';
    
  • 仅禁用文件工具,启用所有其他工具:Disable only file instruments, enable all other instruments:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = IF(NAME LIKE 'wait/io/file/%', 'NO', 'YES');
    
  • 启用mysys库中除那些工具之外的所有工具:Enable all but those instruments in the mysys library:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = CASE WHEN NAME LIKE '%/mysys/%' THEN 'YES' ELSE 'NO' END;
    
  • 禁用特定工具:Disable a specific instrument:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = 'NO'
    WHERE NAME = 'wait/synch/mutex/mysys/TMPDIR_mutex';
    
  • 要切换工具的状态,“翻转”其ENABLED值:To toggle the state of an instrument, “flip” its ENABLED value:

    UPDATE performance_schema.setup_instruments
    SET ENABLED = IF(ENABLED = 'YES', 'NO', 'YES')
    WHERE NAME = 'wait/synch/mutex/mysys/TMPDIR_mutex';
    
  • 禁用所有事件的计时:Disable timing for all events:

    UPDATE performance_schema.setup_instruments
    SET TIMED = 'NO';