- 29.1 Performance Schema 快速入门29.1 Performance Schema Quick Start
- 29.2 Performance Schema 构建配置29.2 Performance Schema Build Configuration
- 29.3 Performance Schema 启动配置29.3 Performance Schema Startup Configuration
- 29.4 Performance Schema 运行时配置29.4 Performance Schema Runtime Configuration
- 29.4.1 Performance Schema 事件计时29.4.1 Performance Schema Event Timing
- 29.4.2 Performance Schema 事件过滤29.4.2 Performance Schema Event Filtering
- 29.4.3 事件预过滤29.4.3 Event Pre-Filtering
- 29.4.4 按工具预过滤29.4.4 Pre-Filtering by Instrument
- 29.4.5 按对象预过滤29.4.5 Pre-Filtering by Object
- 29.4.6 按线程预过滤29.4.6 Pre-Filtering by Thread
- 29.4.7 按消费者预过滤29.4.7 Pre-Filtering by Consumer
- 29.4.8 示例消费者配置29.4.8 Example Consumer Configurations
- 29.4.9 为筛选操作命名仪器或消费者29.4.9 Naming Instruments or Consumers for Filtering Operations
- 29.4.10 确定哪些内容已被仪器化29.4.10 Determining What Is Instrumented
- 29.5 性能模式查询29.5 Performance Schema Queries
- 29.6 性能模式仪器命名约定29.6 Performance Schema Instrument Naming Conventions
- 29.7 性能模式状态监控29.7 Performance Schema Status Monitoring
- 29.8 性能模式原子和分子事件29.8 Performance Schema Atom and Molecule Events
- 29.9 当前和历史事件的性能模式表29.9 Performance Schema Tables for Current and Historical Events
- 29.10 性能模式语句摘要和抽样29.10 Performance Schema Statement Digests and Sampling
- 29.11 性能模式一般表特性29.11 Performance Schema General Table Characteristics
- 29.12 性能模式表描述29.12 Performance Schema Table Descriptions
- 29.12.1 性能模式表参考29.12.1 Performance Schema Table Reference
- 29.12.2 性能模式设置表29.12.2 Performance Schema Setup Tables
- 29.12.3 性能模式实例表29.12.3 Performance Schema Instance Tables
- 29.12.4 性能模式等待事件表29.12.4 Performance Schema Wait Event Tables
- 29.12.5 性能模式阶段事件表29.12.5 Performance Schema Stage Event Tables
- 29.12.6 性能模式语句事件表29.12.6 Performance Schema Statement Event Tables
- 29.12.7 性能模式事务表29.12.7 Performance Schema Transaction Tables
- 29.12.8 性能模式连接表29.12.8 Performance Schema Connection Tables
- 29.12.9 性能模式连接属性表29.12.9 Performance Schema Connection Attribute Tables
- 29.12.10 性能模式用户定义变量表29.12.10 Performance Schema User-Defined Variable Tables
- 29.12.11 性能模式复制表29.12.11 Performance Schema Replication Tables
- 29.12.12 性能模式 NDB 集群表29.12.12 Performance Schema NDB Cluster Tables
- 29.12.13 性能模式锁表29.12.13 Performance Schema Lock Tables
- 29.12.14 性能模式系统变量表29.12.14 Performance Schema System Variable Tables
- 29.12.15 性能模式状态变量表29.12.15 Performance Schema Status Variable Tables
- 29.12.16 性能模式线程池表29.12.16 Performance Schema Thread Pool Tables
- 29.12.17 性能模式防火墙表29.12.17 Performance Schema Firewall Tables
- 29.12.18 性能模式密钥环表29.12.18 Performance Schema Keyring Tables
- 29.12.19 性能模式克隆表29.12.19 Performance Schema Clone Tables
- 29.12.20 性能模式汇总表29.12.20 Performance Schema Summary Tables
- 29.12.21 性能模式遥测表29.12.21 Performance Schema Telemetry Tables
- 29.12.22 性能模式其他表29.12.22 Performance Schema Miscellaneous Tables
- 29.13 性能模式选项和变量参考29.13 Performance Schema Option and Variable Reference
- 29.14 性能模式命令选项29.14 Performance Schema Command Options
- 29.15 性能模式系统变量29.15 Performance Schema System Variables
- 29.16 性能模式状态变量29.16 Performance Schema Status Variables
- 29.17 性能模式内存分配模型29.17 The Performance Schema Memory-Allocation Model
- 29.18 性能模式与插件29.18 Performance Schema and Plugins
- 29.19 使用性能模式诊断问题29.19 Using the Performance Schema to Diagnose Problems
- 29.20 性能模式的限制29.20 Restrictions on Performance Schema
MySQL 性能模式是用于低级监控 MySQL 服务器执行的功能。性能模式具有以下特点:The MySQL Performance Schema is a feature for monitoring MySQL Server execution at a low level. The Performance Schema has these characteristics:
性能模式提供了一种在运行时检查服务器内部执行的方法。它是通过
PERFORMANCE_SCHEMA存储引擎和performance_schema数据库实现的。性能模式主要关注性能数据。这与INFORMATION_SCHEMA不同,后者用于检查元数据。The Performance Schema provides a way to inspect internal execution of the server at runtime. It is implemented using thePERFORMANCE_SCHEMAstorage engine and theperformance_schemadatabase. The Performance Schema focuses primarily on performance data. This differs fromINFORMATION_SCHEMA, which serves for inspection of metadata.性能模式监控服务器事件。“事件”是指服务器执行的任何需要时间且已经被监控以便收集时间信息的操作。通常,事件可以是函数调用、等待操作系统响应、SQL 语句执行的某个阶段(例如解析或排序),或者是整个语句或一组语句。事件收集提供了对服务器及多个存储引擎的同步调用(如互斥锁)、文件和表 I/O、表锁等信息的访问。The Performance Schema monitors server events. An “event” is anything the server does that takes time and has been instrumented so that timing information can be collected. In general, an event could be a function call, a wait for the operating system, a stage of an SQL statement execution such as parsing or sorting, or an entire statement or group of statements. Event collection provides access to information about synchronization calls (such as for mutexes) file and table I/O, table locks, and so forth for the server and for several storage engines.
性能模式事件不同于写入服务器二进制日志的事件(描述数据修改)以及事件调度器事件(这是一种存储程序)。Performance Schema events are distinct from events written to the server's binary log (which describe data modifications) and Event Scheduler events (which are a type of stored program).
性能模式事件是针对特定的 MySQL 服务器实例的。性能模式表被认为是服务器本地的,对它们的更改不会被复制或写入二进制日志。Performance Schema events are specific to a given instance of the MySQL Server. Performance Schema tables are considered local to the server, and changes to them are not replicated or written to the binary log.
可用当前事件,以及事件历史和摘要。这使您能够确定执行过多少次已插装的活动以及这些活动花费了多少时间。事件信息可用于显示特定线程的活动,或与特定对象(如互斥锁或文件)相关的活动。Current events are available, as well as event histories and summaries. This enables you to determine how many times instrumented activities were performed and how much time they took. Event information is available to show the activities of specific threads, or activity associated with particular objects such as a mutex or file.
PERFORMANCE_SCHEMA存储引擎通过服务器源代码中的“插装点”收集事件数据。ThePERFORMANCE_SCHEMAstorage engine collects event data using “instrumentation points” in server source code.收集的事件存储在
performance_schema数据库的表中。可以像查询其他表一样使用SELECT语句查询这些表。Collected events are stored in tables in theperformance_schemadatabase. These tables can be queried usingSELECTstatements like other tables.可以通过 SQL 语句更新
performance_schema数据库中的表来动态修改性能模式配置。配置更改会立即影响数据收集。Performance Schema configuration can be modified dynamically by updating tables in theperformance_schemadatabase through SQL statements. Configuration changes affect data collection immediately.性能模式中的表是内存表,不使用持久性磁盘存储。内容将在服务器启动时重新加载,并在服务器关闭时丢弃。Tables in the Performance Schema are in-memory tables that use no persistent on-disk storage. The contents are repopulated beginning at server startup and discarded at server shutdown.
MySQL 支持的所有平台都提供监控功能。Monitoring is available on all platforms supported by MySQL.
可能存在一些限制:计时器的类型可能因平台而异。适用于存储引擎的仪器可能不会在所有存储引擎中实现。每个第三方引擎的仪器化由引擎维护者负责。另见 第 29.20 节,“Performance Schema 的限制”。Some limitations might apply: The types of timers might vary per platform. Instruments that apply to storage engines might not be implemented for all storage engines. Instrumentation of each third-party engine is the responsibility of the engine maintainer. See also Section 29.20, “Restrictions on Performance Schema”.
数据收集是通过修改服务器源代码以添加仪器来实现的。与复制或事件调度器等其他功能不同,Performance Schema 没有单独的线程。Data collection is implemented by modifying the server source code to add instrumentation. There are no separate threads associated with the Performance Schema, unlike other features such as replication or the Event Scheduler.
Performance Schema 的目的是在尽量减少对服务器性能影响的同时,提供对服务器执行有用信息的访问。其实现遵循以下设计目标:The Performance Schema is intended to provide access to useful information about server execution while having minimal impact on server performance. The implementation follows these design goals:
激活性能模式不会改变服务器行为。例如,它不会导致线程调度发生变化,也不会导致查询执行计划(如
EXPLAIN所示)发生变化。Activating the Performance Schema causes no changes in server behavior. For example, it does not cause thread scheduling to change, and it does not cause query execution plans (as shown byEXPLAIN) to change.服务器监控是持续并无干扰地进行的,开销非常小。激活性能模式不会使服务器无法使用。Server monitoring occurs continuously and unobtrusively with very little overhead. Activating the Performance Schema does not make the server unusable.
解析器保持不变。没有新的关键字或语句。The parser is unchanged. There are no new keywords or statements.
即使性能模式内部失败,服务器代码的执行也会正常进行。Execution of server code proceeds normally even if the Performance Schema fails internally.
当在事件收集初期处理和稍后事件检索之间需要选择时,优先考虑加快收集速度。这是因为收集是持续进行的,而检索是按需进行的,可能永远不会发生。When there is a choice between performing processing during event collection initially or during event retrieval later, priority is given to making collection faster. This is because collection is ongoing whereas retrieval is on demand and might never happen at all.
大多数 Performance Schema 表都有索引,这使优化器可以访问除全表扫描之外的执行计划。有关更多信息,请参见 第 10.2.4 节,“优化 Performance Schema 查询”。Most Performance Schema tables have indexes, which gives the optimizer access to execution plans other than full table scans. For more information, see Section 10.2.4, “Optimizing Performance Schema Queries”.
添加新的检测点很容易。It is easy to add new instrumentation points.
检测是有版本控制的。如果检测实现发生变化,先前检测过的代码仍然可以工作。这对第三方插件的开发者有利,因为不需要升级每个插件以与最新的 Performance Schema 改动保持同步。Instrumentation is versioned. If the instrumentation implementation changes, previously instrumented code continues to work. This benefits developers of third-party plugins because it is not necessary to upgrade each plugin to stay synchronized with the latest Performance Schema changes.
MySQL 的 sys 架构是一组对象,提供对 Performance Schema 收集的数据的便捷访问。sys 架构默认安装。有关使用说明,请参见 第 30 章,MySQL sys 架构。
The MySQL sys schema is a set of objects that
provides convenient access to data collected by the Performance
Schema. The sys schema is installed by default.
For usage instructions, see Chapter 30, MySQL sys Schema.