

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon RDS for MariaDB 或 MySQL 上 Performance Insights 的效能結構描述概觀
<a name="USER_PerfInsights.EnableMySQL"></a>

效能結構描述為選用功能，用來在詳細資料低層級監控 Amazon RDS for MariaDB 或 MySQL 執行時間效能。效能結構描述專為盡量降低對資料庫效能的影響所設計。您在有或無效能結構描述的狀況下皆可使用績效詳情。

**Topics**
+ [效能結構描述概觀](#USER_PerfInsights.EnableMySQL.overview)
+ [Performance Insights 和 Performance Schema](#USER_PerfInsights.effect-of-pfs)
+ [透過績效詳情自動管理效能結構描述](#USER_PerfInsights.EnableMySQL.options)
+ [重新開機對效能結構描述的影響](#USER_PerfInsights.EnableMySQL.reboot)
+ [決定績效詳情是否管理效能結構描述](USER_PerfInsights.EnableMySQL.determining-status.md)
+ [在 Amazon RDS for MariaDB 或 MySQL 上開啟效能結構描述](USER_PerfInsights.EnableMySQL.RDS.md)

## 效能結構描述概觀
<a name="USER_PerfInsights.EnableMySQL.overview"></a>

效能結構描述會監控 MariaDB 及 MySQL資料庫 中的事件。*事件*是個佔用時間的資料庫伺服器動作，並經過分析，可收集計時資訊。事件的範例如下：
+ 函數呼叫
+ 等待作業系統
+ SQL 執行的階段
+ SQL 陳述式的群組

`PERFORMANCE_SCHEMA` 儲存引擎是一種用於實作效能結構描述功能的機制。此引擎會使用資料庫來源碼中的檢測來收集事件資料。引擎會將事件儲存於 `performance_schema` 資料庫的僅限記憶體表格中。您可查詢 `performance_schema`，就像您可以查詢任何其他表格一樣。如需 MySQL 效能結構描述的詳細資訊，請參閱 [MySQL 參考手冊](https://dev.mysql.com/doc/refman/8.0/en/performance-schema.html)中的 *MySQL 效能結構描述*。

## Performance Insights 和 Performance Schema
<a name="USER_PerfInsights.effect-of-pfs"></a>

績效詳情和效能結構描述是獨立的功能，但彼此互相連接。Performance Insights 對於 Amazon RDS for MariaDB 或 MySQL 的行為取決於 Performance Schema 是否開啟，如果是的話，Performance Insights 是否自動管理 Performance Schema。下表說明行為。


| Performance Schema 已開啟 | Performance Insights 管理模式 | Performance Insights 行為 | 
| --- | --- | --- | 
|  是  |  自動  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/USER_PerfInsights.EnableMySQL.html)  | 
|  是  |  手動  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/USER_PerfInsights.EnableMySQL.html)  | 
|  否  |  N/A  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/USER_PerfInsights.EnableMySQL.html)  | 

## 透過績效詳情自動管理效能結構描述
<a name="USER_PerfInsights.EnableMySQL.options"></a>

當您在開啟績效詳情的狀況下建立 Amazon RDS for MariaDB 或 MySQL 資料庫執行個體時，也會開啟效能結構描述。在此狀況下，績效詳情會自動管理您的效能結構描述參數。這是建議的組態。

當 Performance Insights 自動管理效能結構描述時，`performance_schema` 的**來源**為 `System default`。

**注意**  
t4g.medium 執行個體類別不支援效能結構描述的自動管理。

若您手動變更 `performance_schema` 參數，但稍後想變更為自動管理，請參閱[在 Amazon RDS for MariaDB 或 MySQL 上開啟效能結構描述](USER_PerfInsights.EnableMySQL.RDS.md)。

**重要**  
當績效詳情開啟效能結構描述時，其不會變更參數群組值。不過，這些值會在執行的資料庫執行個體上進行變更。查看變更值的唯一方法是執行 `SHOW GLOBAL VARIABLES` 命令。

## 重新開機對效能結構描述的影響
<a name="USER_PerfInsights.EnableMySQL.reboot"></a>

績效詳情和效能結構描述在資料庫執行個體重新開機的要求方面有所不同：

**效能結構描述**  
若要開啟或關閉此功能，您必須重新開機資料庫執行個體。

**Performance Insights**  
若要開啟或關閉此功能，不需要重新開機資料庫執行個體。

如果效能結構描述目前未開啟，並且您在未重新開機資料庫執行個體的情況下開啟績效詳情，則不會開啟效能結構描述。

# 決定績效詳情是否管理效能結構描述
<a name="USER_PerfInsights.EnableMySQL.determining-status"></a>

若要了解 Performance Insights 目前是否正在管理所有受支援主要引擎版本的效能結構描述，請查看下表。


| performance\$1schema 參數的設定 | 來源欄的設定 | 績效詳情管理效能結構描述 | 
| --- | --- | --- | 
| 0 | System default | 是 | 
| 0 或 1 | Modified | 否 | 

在下列程序中，您會判斷 Performance Insights 是否自動管理效能結構描述。

**若要判斷績效詳情是否自動管理效能結構描述**

1. 登入 AWS 管理主控台 ，並在 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)：// 開啟 Amazon RDS 主控台。

1. 選擇 **Parameter groups (參數群組)**。

1. 選擇資料庫執行個體的參數群組名稱。

1. 在搜尋列中，輸入 **performance\$1schema**。

1. 檢查**來源**是否為系統預設值，而**值**是否為 **0**。若是如此，績效詳情正在自動管理效能結構描述。

   在這裡顯示的範例中，Performance Insights 並未自動管理效能結構描述。  
![\[顯示 performance_schema 參數的設定已修改。\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/images/perf_schema_user.png)

# 在 Amazon RDS for MariaDB 或 MySQL 上開啟效能結構描述
<a name="USER_PerfInsights.EnableMySQL.RDS"></a>

假設您的資料庫執行個體或多可用區域資料庫叢集的績效詳情已啟用，但目前並未管理效能結構描述。如果要允許績效詳情自動管理效能結構描述，請完成以下步驟。

**設定效能結構描述為自動管理**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 選擇 **Parameter groups (參數群組)**。

1. 選擇資料庫執行個體或多可用區域資料庫叢集的參數群組名稱。

1. 選擇**編輯**。

1. 在搜尋列中，輸入 **performance\$1schema**。

1. 選取 `performance_schema` 參數。

1. 選擇**設定為預設值**。

1. 選擇**將值設定為預設值**來確認。

1. 選擇 **Save Changes** (儲存變更)。

1. 重新啟動資料庫執行個體或多可用區域資料庫叢集。
**重要**  
每當您開啟或關閉效能結構描述時，請務必重新開機資料庫執行個體或多可用區域資料庫叢集。

如需修改執行個體參數的相關資訊，請參閱 [修改 Amazon RDS 中的資料庫參數群組中的參數](USER_WorkingWithParamGroups.Modifying.md)。如需儀表板中的詳細資訊，請參閱[使用績效詳情儀表板來分析指標](USER_PerfInsights.UsingDashboard.md)。如需 MySQL 效能結構描述的詳細資訊，請參閱 MySQL 文件中的 [MySQL 效能結構描述](https://dev.mysql.com/doc/refman/8.0/en/performance-schema.html) (適用於 8.0) 和 [MySQL 效能結構描述](https://dev.mysql.com/doc/refman/8.4/en/performance-schema.html) (適用於 8.4)。