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.4 按检测信号预过滤

表格setup_instruments列出了可用的仪器:

Press CTRL+C to copy
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列为YESNO。要配置是否收集启用仪器的计时信息,设置其TIMED值为YESNO。将TIMED列的设置会影响性能模式表格内容,详见第29.4.1节,“性能模式事件计时”

大多数setup_instruments行的修改会立即影响监控。对于某些仪器,修改只在服务器启动时生效,在运行时更改无效。这主要影响服务器中的互斥体、条件和读写锁定,尽管可能还有其他用于此目的的仪器。

表格setup_instruments提供了事件生产的最基本形式控制。为了进一步根据监控的对象类型或线程来精细化事件生产,可能会使用其他表格,详见第29.4.3节,“事件预过滤”

以下是对表格setup_instruments的可能操作。这些更改,如其他预过滤操作一样,对所有用户都有效。一些查询使用LIKE运算符和模式匹配仪器名称。关于指定模式以选择仪器的更多信息,请参阅第29.4.9节,“为过滤操作命名仪器或消费者”

  • 禁用所有仪器:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET ENABLED = 'NO';

    现在不再收集任何事件。

  • 禁用所有文件仪器,并将其添加到当前禁用的仪器集中:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET ENABLED = 'NO' WHERE NAME LIKE 'wait/io/file/%';
  • 只禁用文件仪器,启用其他所有仪器:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET ENABLED = IF(NAME LIKE 'wait/io/file/%', 'NO', 'YES');
  • 启用除mysys库中的仪器之外的所有仪器:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET ENABLED = CASE WHEN NAME LIKE '%/mysys/%' THEN 'YES' ELSE 'NO' END;
  • 禁用特定仪器:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET ENABLED = 'NO' WHERE NAME = 'wait/synch/mutex/mysys/TMPDIR_mutex';
  • 要切换仪器状态,将其ENABLED值进行翻转:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET ENABLED = IF(ENABLED = 'YES', 'NO', 'YES') WHERE NAME = 'wait/synch/mutex/mysys/TMPDIR_mutex';
  • 禁用所有事件的计时:

    Press CTRL+C to copy
    UPDATE performance_schema.setup_instruments SET TIMED = 'NO';