本节简要介绍了 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 queryperformance_schematables 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 forInnoDB. To viewInnoDB-related instruments, you can query thesetup_instrumentstable for instrument names that contain 'innodb'.mysql>
SELECT *FROM performance_schema.setup_instrumentsWHERE 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 instrumentedInnoDBobjects, you can query Performance Schema instances tables, which provide additional information about instrumented objects. Instance tables relevant toInnoDBinclude:mutex_instances表Themutex_instancestablerwlock_instances表Therwlock_instancestablecond_instances表Thecond_instancestablefile_instances表Thefile_instancestable
Note与
InnoDB缓冲池相关的互斥锁和读写锁未包含在此覆盖范围内;同样,这也适用于SHOW ENGINE INNODB MUTEX语句的输出。Mutexes and RW-locks related to theInnoDBbuffer pool are not included in this coverage; the same applies to the output of theSHOW ENGINE INNODB MUTEXstatement.例如,要查看在执行文件 I/O 仪表时性能模式看到的仪表化
InnoDB文件对象的信息,您可以发出以下查询:For example, to view information about instrumentedInnoDBfile objects seen by the Performance Schema when executing file I/O instrumentation, you might issue the following query:mysql>
SELECT *FROM performance_schema.file_instancesWHERE 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 withperformance_schematables that storeInnoDBevent data. Tables relevant toInnoDB-related events include:等待事件 表,存储等待事件。The Wait Event tables, which store wait events.
汇总表格,提供随时间终止事件的聚合信息。汇总表格包括文件 I/O 汇总表,该表汇总有关 I/O 操作的信息。The Summary tables, which provide aggregated information for terminated events over time. Summary tables include file I/O summary tables, which aggregate information about I/O operations.
阶段事件 表,用于存储
InnoDBALTER TABLE和缓冲池加载操作的事件数据。有关更多信息,请参阅 第 17.16.1 节,“使用性能模式监控 InnoDB 表的 ALTER TABLE 进度”,以及 使用性能模式监控缓冲池加载进度。Stage Event tables, which store event data forInnoDBALTER TABLEand buffer pool load operations. For more information, see Section 17.16.1, “Monitoring ALTER TABLE Progress for InnoDB Tables Using Performance Schema”, and Monitoring Buffer Pool Load Progress Using Performance Schema.
如果您只对
InnoDB相关的对象感兴趣,在查询这些表时使用子句WHERE EVENT_NAME LIKE '%innodb%'或WHERE NAME LIKE '%innodb%'(根据需要)。If you are only interested inInnoDB-related objects, use the clauseWHERE EVENT_NAME LIKE '%innodb%'orWHERE NAME LIKE '%innodb%'(as required) when querying these tables.