

# Aurora MySQL 上性能详情的性能架构概述
<a name="USER_PerfInsights.EnableMySQL"></a>

Performance Schema 是一项可选功能，用来监控 Aurora MySQL 低细节层次的运行时性能。性能架构旨在将对数据库性能的影响降至最低。Performance Insights 是一个单独的功能，无论有没有 Performance Schema，您都可以使用该功能。

**Topics**
+ [性能架构概览](#USER_PerfInsights.EnableMySQL.overview)
+ [性能详情和性能架构](#USER_PerfInsights.effect-of-pfs)
+ [让 Performance Insights 自动管理 Performance Schema](#USER_PerfInsights.EnableMySQL.options)
+ [重启对 Performance Schema 的影响](#USER_PerfInsights.EnableMySQL.reboot)
+ [确定性能详情是否正在管理 Performance Schema](USER_PerfInsights.EnableMySQL.determining-status.md)
+ [为 Aurora MySQL 开启 Performance Schema](USER_PerfInsights.EnableMySQL.RDS.md)

## 性能架构概览
<a name="USER_PerfInsights.EnableMySQL.overview"></a>

Performance Schema 监控 Aurora MySQL 数据库中的事件。*事件*是一项消耗时间的数据库服务器操作，已进行了分析，以便收集计时信息。以下为事件示例：
+ 函数调用
+ 等待操作系统
+ SQL 执行阶段
+ SQL 语句组

`PERFORMANCE_SCHEMA` 存储引擎是实施 Performance Schema 功能的一种机制。该引擎使用数据库源代码中的分析来收集事件数据。该引擎将事件存储在 `performance_schema` 数据库的 memory-only 表中。您可以查询 `performance_schema`，就像您可以查询任何其他表一样。有关更多信息，请参阅 *MySQL 参考手册*中的 [MySQL Performance Schema](https://dev.mysql.com/doc/refman/8.0/en/performance-schema.html)。

## 性能详情和性能架构
<a name="USER_PerfInsights.effect-of-pfs"></a>

Performance Insights 和 Performance Schema 是独立的功能，但它们相互关联。Aurora MySQL 的性能详情的行为取决于性能架构是否已开启，如果已开启，则取决于性能详情是否自动管理性能架构。下表描述了该行为。


| 性能架构已开启 | 性能详情管理模式 | 性能详情行为 | 
| --- | --- | --- | 
|  是  |  自动  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights.EnableMySQL.html)  | 
|  是  |  手动  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights.EnableMySQL.html)  | 
|  否  |  不适用  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights.EnableMySQL.html)  | 

## 让 Performance Insights 自动管理 Performance Schema
<a name="USER_PerfInsights.EnableMySQL.options"></a>

在打开 Performance Insights 的情况下创建 Aurora MySQL 数据库实例时，也会打开 Performance Schema。在这种情况下，性能详情会自动管理您的性能架构参数。这是建议的配置。

当 Performance Insights 自动管理 Performance Schema 时，`performance_schema` 的**来源**是 `System default`。

**注意**  
t4g.medium 实例类不支持自动管理性能架构。

您也可以手动管理 Performance Schema。如果选择此选项，请根据下表中的值设置参数。


| 参数名称 | 参数值 | 
| --- | --- | 
|  `performance_schema`  |  `1`（**Source**（源）列具有值 `Modified`）  | 
|  `performance-schema-consumer-events-waits-current`  |  `ON`  | 
|  `performance-schema-instrument`  |  `wait/%=ON`  | 
|  `performance_schema_consumer_global_instrumentation`  |  `1`  | 
|  `performance_schema_consumer_thread_instrumentation`  |  `1`  | 

如果手动更改 `performance_schema` 参数值，然后稍后想恢复为自动管理，请参阅[为 Aurora MySQL 开启 Performance Schema](USER_PerfInsights.EnableMySQL.RDS.md)。

**重要**  
当 Performance Insights 打开 Performance Schema 时，它不会更改参数组值。但是，正在运行的数据库实例上的值会更改。查看更改后的值的唯一方法是运行 `SHOW GLOBAL VARIABLES` 命令。

## 重启对 Performance Schema 的影响
<a name="USER_PerfInsights.EnableMySQL.reboot"></a>

Performance Insights 和 Performance Schema 对数据库实例重启的要求不同：

**Performance Schema**  
要打开或关闭此功能，您必须重启数据库实例。

**性能详情**  
要打开或关闭此功能，您不需要重启数据库实例。

如果当前未打开 Performance Schema，并且您在不重启数据库实例的情况下打开 Performance Insights，则不会打开 Performance Schema。