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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 17 InnoDB 存储引擎 / 17.16 InnoDB 与 MySQL 性能模式集成
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

17.16 InnoDB 与 MySQL 性能模式的整合17.16 InnoDB Integration with MySQL Performance Schema

本节简要介绍了 InnoDB 与性能模式的整合。有关全面的性能模式文档,请参见 第 29 章,MySQL 性能模式。This section provides a brief introduction to InnoDB integration with Performance Schema. For comprehensive Performance Schema documentation, see Chapter 29, MySQL Performance Schema.

您可以使用 MySQL 性能架构功能来分析某些内部 InnoDB 操作。这种类型的调优主要针对评估优化策略以克服性能瓶颈的高级用户。数据库管理员也可以使用此功能进行容量规划,以查看其典型工作负载是否在特定的 CPU、内存和磁盘存储组合下遇到任何性能瓶颈;如果有,则判断通过增加系统某部分的容量是否可以提高性能。You can profile certain internal InnoDB operations using the MySQL Performance Schema feature. This type of tuning is primarily for expert users who evaluate optimization strategies to overcome performance bottlenecks. DBAs can also use this feature for capacity planning, to see whether their typical workload encounters any performance bottlenecks with a particular combination of CPU, RAM, and disk storage; and if so, to judge whether performance can be improved by increasing the capacity of some part of the system.

要使用此功能检查 InnoDB 性能:To use this feature to examine InnoDB performance:

  • 您必须大致了解如何使用性能模式功能。例如,您应知道如何启用工具和消费者,以及如何查询performance_schema 表以检索数据。有关入门概述,请参见第 29.1 节,“性能模式快速入门”。You must be generally familiar with how to use the Performance Schema feature. For example, you should know how enable instruments and consumers, and how to query performance_schema tables to retrieve data. For an introductory overview, see Section 29.1, “Performance Schema Quick Start”.

  • 您应该熟悉可用于 InnoDB 的 Performance Schema 工具。要查看与 InnoDB 相关的工具,您可以查询 setup_instruments 表中包含 'innodb' 的工具名称。You should be familiar with Performance Schema instruments that are available for InnoDB. To view InnoDB-related instruments, you can query the setup_instruments table for instrument names that contain '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)
    

    有关被监控的 InnoDB 对象的更多信息,您可以查询 Performance Schema 实例表,这些表提供有关被监控对象的附加信息。与 InnoDB 相关的实例表包括:For additional information about the instrumented InnoDB objects, you can query Performance Schema instances tables, which provide additional information about instrumented objects. Instance tables relevant to InnoDB include:

    Note

    与 InnoDB 缓冲池相关的互斥锁和读写锁未包含在此覆盖范围内;同样,这也适用于 SHOW ENGINE INNODB MUTEX 语句的输出。Mutexes and RW-locks related to the InnoDB buffer pool are not included in this coverage; the same applies to the output of the SHOW ENGINE INNODB MUTEX statement.

    例如,要查看在执行文件 I/O 仪表时性能模式看到的仪表化 InnoDB 文件对象的信息,您可以发出以下查询:For example, to view information about instrumented InnoDB file objects seen by the Performance Schema when executing file I/O instrumentation, you might issue the following query:

    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 相关事件相关的表包括:You should be familiar with performance_schema tables that store InnoDB event data. Tables relevant to InnoDB-related events include:

    如果您只对InnoDB相关的对象感兴趣,在查询这些表时使用子句WHERE EVENT_NAME LIKE '%innodb%'或WHERE NAME LIKE '%innodb%'(根据需要)。If you are only interested in InnoDB-related objects, use the clause WHERE EVENT_NAME LIKE '%innodb%' or WHERE NAME LIKE '%innodb%' (as required) when querying these tables.