文件首頁
MySQL 9.0 參考手冊
相關文件 下載本手冊
PDF (US Ltr) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 258.2Kb
Man Pages (Zip) - 365.3Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 參考手冊  /  MySQL Performance Schema  /  Performance Schema 記憶體配置模型

29.17 Performance Schema 記憶體配置模型

Performance Schema 使用此記憶體配置模型

  • 可能會在伺服器啟動時配置記憶體

  • 可能會在伺服器運作期間配置額外記憶體

  • 在伺服器運作期間絕不釋放記憶體(儘管可能會回收)

  • 在關機時釋放所有已使用的記憶體

結果是放寬記憶體限制,以便在較少的組態下使用 Performance Schema,並減少記憶體佔用,使消耗量隨著伺服器負載而調整。使用的記憶體取決於實際看到的負載,而不是估計或明確設定的負載。

數個 Performance Schema 大小調整參數是自動調整的,除非您想要建立明確的記憶體配置限制,否則不需要明確設定這些參數。

performance_schema_accounts_size
performance_schema_hosts_size
performance_schema_max_cond_instances
performance_schema_max_file_instances
performance_schema_max_index_stat
performance_schema_max_metadata_locks
performance_schema_max_mutex_instances
performance_schema_max_prepared_statements_instances
performance_schema_max_program_instances
performance_schema_max_rwlock_instances
performance_schema_max_socket_instances
performance_schema_max_table_handles
performance_schema_max_table_instances
performance_schema_max_table_lock_stat
performance_schema_max_thread_instances
performance_schema_users_size

對於自動調整的參數,組態如下所示

  • 將值設定為 -1(預設值)時,參數會自動調整

    • 對應的內部緩衝區一開始是空的,且未配置任何記憶體。

    • 當 Performance Schema 收集資料時,會在對應的緩衝區中配置記憶體。緩衝區大小不受限制,可能會隨著負載而增長。

  • 將值設定為 0

    • 對應的內部緩衝區一開始是空的,且未配置任何記憶體。

  • 將值設定為 N > 0

    • 對應的內部緩衝區一開始是空的,且未配置任何記憶體。

    • 當 Performance Schema 收集資料時,會在對應的緩衝區中配置記憶體,直到緩衝區大小達到 N 為止。

    • 一旦緩衝區大小達到 N,就不會再配置更多記憶體。Performance Schema 為此緩衝區收集的資料會遺失,並且會遞增任何對應的 遺失執行個體計數器。

若要查看 Performance Schema 使用多少記憶體,請檢查為此目的設計的工具。Performance Schema 會在內部配置記憶體,並將每個緩衝區與專用的工具關聯,以便將記憶體消耗追溯到個別緩衝區。以 memory/performance_schema/ 為前綴命名的工具會顯示為這些內部緩衝區配置了多少記憶體。這些緩衝區是伺服器全域的,因此這些工具只會顯示在 memory_summary_global_by_event_name 表格中,而不會顯示在其他 memory_summary_by_xxx_by_event_name 表格中。

此查詢會顯示與記憶體工具相關聯的資訊

SELECT * FROM performance_schema.memory_summary_global_by_event_name
WHERE EVENT_NAME LIKE 'memory/performance_schema/%';