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


MySQL 8.4 Reference Manual  /  The InnoDB Storage Engine  /  InnoDB Integration with MySQL Performance Schema

17.16 InnoDB 与 MySQL 性能模式集成

本节提供了对 InnoDB 与性能模式集成的简要介绍。对于全面性能模式文档,请见第 29 章,MySQL 性能模式

您可以使用 MySQL 的性能模式特性对某些内部 InnoDB 操作进行 profiling。这类优化策略主要是为专家用户,用于评估优化策略以克服性能瓶颈。DBA 也可以使用该特性进行容量规划,以查看是否在某种 CPU、RAM 和磁盘存储组合下出现性能瓶颈,如果出现,可以判断是否可以通过增加系统某部分的容量来改善性能。

要使用该特性来检查 InnoDB 性能:

  • 您应该对性能_schema特性的使用有基本了解,例如,您应该知道如何启用仪器和消费者,以及如何查询performance_schema表来检索数据。对于简介,请见第29.1节,“性能_schema快速入门”.

  • 您应该熟悉InnoDB的性能_schema仪器。要查看InnoDB-相关仪器,可以查询setup_instruments表,查找包含'innodb'的仪器名称。

    mysql> SELECT *
           FROM performance_schema.setup_instruments
           WHERE NAME LIKE '%innodb%';
    +-------------------------------------------------------+---------+-------+
    | NAME                                                  | ENABLED | TIMED |
    +-------------------------------------------------------+---------+-------+
    | wait/synch/mutex/innodb/commit_cond_mutex             | NO      | NO    |
    | wait/synch/mutex/innodb/innobase_share_mutex          | NO      | NO    |
    | wait/synch/mutex/innodb/autoinc_mutex                 | NO      | NO    |
    | wait/synch/mutex/innodb/buf_pool_mutex                | NO      | NO    |
    | wait/synch/mutex/innodb/buf_pool_zip_mutex            | NO      | NO    |
    | wait/synch/mutex/innodb/cache_last_read_mutex         | NO      | NO    |
    | wait/synch/mutex/innodb/dict_foreign_err_mutex        | NO      | NO    |
    | wait/synch/mutex/innodb/dict_sys_mutex                | NO      | NO    |
    | wait/synch/mutex/innodb/recalc_pool_mutex             | NO      | NO    |
    ...
    | 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   |
    | stage/innodb/alter table (end)                        | YES     | YES   |
    | stage/innodb/alter table (flush)                      | YES     | YES   |
    | stage/innodb/alter table (insert)                     | YES     | YES   |
    | stage/innodb/alter table (log apply index)            | YES     | YES   |
    | stage/innodb/alter table (log apply table)            | YES     | YES   |
    | stage/innodb/alter table (merge sort)                 | YES     | YES   |
    | stage/innodb/alter table (read PK and internal sort)  | YES     | YES   |
    | stage/innodb/buffer pool load                         | YES     | YES   |
    | memory/innodb/buf_buf_pool                            | NO      | NO    |
    | memory/innodb/dict_stats_bg_recalc_pool_t             | NO      | NO    |
    | memory/innodb/dict_stats_index_map_t                  | NO      | NO    |
    | memory/innodb/dict_stats_n_diff_on_level              | NO      | NO    |
    | memory/innodb/other                                   | NO      | NO    |
    | memory/innodb/row_log_buf                             | NO      | NO    |
    | memory/innodb/row_merge_sort                          | NO      | NO    |
    | memory/innodb/std                                     | NO      | NO    |
    | memory/innodb/sync_debug_latches                      | NO      | NO    |
    | memory/innodb/trx_sys_t::rw_trx_ids                   | NO      | NO    |
    ...
    +-------------------------------------------------------+---------+-------+
    155 rows in set (0.00 sec)

    关于instrumentedInnoDB对象的additional信息,可以查询性能_schema实例表,这些表提供了关于instrumented对象的additional信息。与InnoDB相关的实例表包括:

    Note

    InnoDB 缓冲池相关的互斥锁和读写锁不在本次覆盖范围内;同样,SHOW ENGINE INNODB MUTEX 语句的输出也没有包含这些信息。

    例如,要查看性能chema在执行文件I/Oinstrumentation时对InnoDB文件对象的信息,您可能需要发出以下查询:

    mysql> SELECT *
           FROM performance_schema.file_instances
           WHERE EVENT_NAME LIKE '%innodb%'\G
    *************************** 1. row ***************************
     FILE_NAME: /home/dtprice/mysql-8.4/data/ibdata1
    EVENT_NAME: wait/io/file/innodb/innodb_data_file
    OPEN_COUNT: 3
    *************************** 2. row ***************************
     FILE_NAME: /home/dtprice/mysql-8.4/data/#ib_16384_0.dblwr
    EVENT_NAME: wait/io/file/innodb/innodb_dblwr_file
    OPEN_COUNT: 2
    *************************** 3. row ***************************
     FILE_NAME: /home/dtprice/mysql-8.4/data/#ib_16384_1.dblwr
    EVENT_NAME: wait/io/file/mysql-8.4/innodb_dblwr_file
    OPEN_COUNT: 2
    ...
  • 您应该熟悉存储InnoDB事件数据的performance_schema表。与InnoDB相关事件的表包括:

    如果您只对InnoDB-相关对象感兴趣,请在查询这些表时使用子句WHERE EVENT_NAME LIKE '%innodb%'WHERE NAME LIKE '%innodb%'(如需)。