性能模式实现了几个提供配置信息的系统变量:
mysql> SHOW VARIABLES LIKE 'perf%';
+--------------------------------------------------------+---------+
| Variable_name | Value |
+--------------------------------------------------------+---------+
| performance_schema | ON |
| performance_schema_accounts_size | 100 |
| performance_schema_digests_size | 200 |
| performance_schema_events_stages_history_long_size | 10000 |
| performance_schema_events_stages_history_size | 10 |
| performance_schema_events_statements_history_long_size | 10000 |
| performance_schema_events_statements_history_size | 10 |
| performance_schema_events_waits_history_long_size | 10000 |
| performance_schema_events_waits_history_size | 10 |
| performance_schema_hosts_size | 100 |
| performance_schema_max_cond_classes | 80 |
| performance_schema_max_cond_instances | 1000 |
| performance_schema_max_file_classes | 50 |
| performance_schema_max_file_handles | 32768 |
| performance_schema_max_file_instances | 10000 |
| performance_schema_max_mutex_classes | 200 |
| performance_schema_max_mutex_instances | 1000000 |
| performance_schema_max_rwlock_classes | 30 |
| performance_schema_max_rwlock_instances | 1000000 |
| performance_schema_max_socket_classes | 10 |
| performance_schema_max_socket_instances | 1000 |
| performance_schema_max_stage_classes | 150 |
| performance_schema_max_statement_classes | 165 |
| performance_schema_max_table_handles | 10000 |
| performance_schema_max_table_instances | 1000 |
| performance_schema_max_thread_classes | 50 |
| performance_schema_max_thread_instances | 1000 |
| performance_schema_session_connect_attrs_size | 512 |
| performance_schema_setup_actors_size | 100 |
| performance_schema_setup_objects_size | 100 |
| performance_schema_users_size | 100 |
+--------------------------------------------------------+---------+Performance Schema 系统变量可以在服务器启动时在命令行或选项文件中设置,许多可以在运行时设置。请参阅 第 22.13 节,“性能模式选项和变量参考”。
如果未明确设置,性能模式会在服务器启动时自动调整其几个参数的值。有关详细信息,请参阅 第 22.3 节,“性能模式启动配置”。
Performance Schema 系统变量具有以下含义:
-
命令行格式 --performance-schema[={OFF|ON}]系统变量 performance_schema范围 全球的 动态的 不 类型 布尔值 默认值 ON该变量的值为
ONorOFF,表示性能模式是否启用。默认情况下,该值为ON。在服务器启动时,您可以指定此变量不带任何值或值为ON或 1 以启用它,或者指定此变量的值为OFF或 0 以禁用它。 performance_schema_accounts_size命令行格式 --performance-schema-accounts-size=#系统变量 performance_schema_accounts_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 1048576表中的行数
accounts。如果此变量为 0,则 Performance Schema 不会在accounts表中维护连接统计信息。performance_schema_digests_size命令行格式 --performance-schema-digests-size=#系统变量 performance_schema_digests_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的最大行数
events_statements_summary_by_digest。如果超过此最大值以致无法检测摘要,则性能模式会增加Performance_schema_digest_lost状态变量。有关语句摘要的更多信息,请参阅 第 22.10 节,“性能模式语句摘要”。
performance_schema_events_stages_history_long_size命令行格式 --performance-schema-events-stages-history-long-size=#系统变量 performance_schema_events_stages_history_long_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
events_stages_history_long。performance_schema_events_stages_history_size命令行格式 --performance-schema-events-stages-history-size=#系统变量 performance_schema_events_stages_history_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1024表中每个线程的行数
events_stages_history。performance_schema_events_statements_history_long_size命令行格式 --performance-schema-events-statements-history-long-size=#系统变量 performance_schema_events_statements_history_long_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
events_statements_history_long。performance_schema_events_statements_history_size命令行格式 --performance-schema-events-statements-history-size=#系统变量 performance_schema_events_statements_history_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1024表中每个线程的行数
events_statements_history。performance_schema_events_waits_history_long_size命令行格式 --performance-schema-events-waits-history-long-size=#系统变量 performance_schema_events_waits_history_long_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
events_waits_history_long。performance_schema_events_waits_history_size命令行格式 --performance-schema-events-waits-history-size=#系统变量 performance_schema_events_waits_history_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1024表中每个线程的行数
events_waits_history。-
命令行格式 --performance-schema-hosts-size=#系统变量 performance_schema_hosts_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 1048576表中的行数
hosts。如果此变量为 0,则 Performance Schema 不会在hosts表中维护连接统计信息。 performance_schema_max_cond_classes命令行格式 --performance-schema-max-cond-classes=#系统变量 performance_schema_max_cond_classes范围 全球的 动态的 不 类型 整数 默认值 80最小值 0最大值 256条件工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_cond_instances命令行格式 --performance-schema-max-cond-instances=#系统变量 performance_schema_max_cond_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1024检测条件对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_digest_length命令行格式 --performance-schema-max-digest-length=#介绍 5.6.26 系统变量 performance_schema_max_digest_length范围 全球的 动态的 不 类型 整数 默认值 1024最小值 0最大值 1048576单元 字节 每个语句保留的最大内存字节数,用于计算性能模式中的规范化语句摘要值。该变量与
max_digest_length; 请参阅第 5.1.7 节“服务器系统变量”中对该变量的描述 。有关语句摘要的更多信息,包括有关内存使用的注意事项,请参阅 第 22.10 节,“性能模式语句摘要”。
performance_schema_max_file_classes命令行格式 --performance-schema-max-file-classes=#系统变量 performance_schema_max_file_classes范围 全球的 动态的 不 类型 整数 默认值 50最小值 0最大值 256文件工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_file_handles命令行格式 --performance-schema-max-file-handles=#系统变量 performance_schema_max_file_handles范围 全球的 动态的 不 类型 整数 默认值 32768最小值 0最大值 1048576打开的文件对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
的值
performance_schema_max_file_handles应大于 的值open_files_limit:open_files_limit影响服务器可以支持的最大打开文件句柄数,并performance_schema_max_file_handles影响可以检测这些文件句柄的数量。performance_schema_max_file_instances命令行格式 --performance-schema-max-file-instances=#系统变量 performance_schema_max_file_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)检测文件对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_mutex_classes命令行格式 --performance-schema-max-mutex-classes=#系统变量 performance_schema_max_mutex_classes范围 全球的 动态的 不 类型 整数 默认值 200最小值 0最大值 256互斥仪器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_mutex_instances命令行格式 --performance-schema-max-mutex-instances=#系统变量 performance_schema_max_mutex_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 104857600检测互斥对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_rwlock_classes命令行格式 --performance-schema-max-rwlock-classes=#系统变量 performance_schema_max_rwlock_classes范围 全球的 动态的 不 类型 整数 默认值(≥ 5.6.15) 40默认值(≤ 5.6.14) 30最小值 0最大值 256rwlock 仪器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_rwlock_instances命令行格式 --performance-schema-max-rwlock-instances=#系统变量 performance_schema_max_rwlock_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 104857600检测的 rwlock 对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_socket_classes命令行格式 --performance-schema-max-socket-classes=#系统变量 performance_schema_max_socket_classes范围 全球的 动态的 不 类型 整数 默认值 10最小值 0最大值 256套接字工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_socket_instances命令行格式 --performance-schema-max-socket-instances=#系统变量 performance_schema_max_socket_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测套接字对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_stage_classes命令行格式 --performance-schema-max-stage-classes=#系统变量 performance_schema_max_stage_classes范围 全球的 动态的 不 类型 整数 默认值 150最小值 0最大值 256舞台乐器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_statement_classes命令行格式 --performance-schema-max-statement-classes=#系统变量 performance_schema_max_statement_classes范围 全球的 动态的 不 类型 整数 最小值 0最大值 256语句工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
默认值是在服务器构建时根据客户端/服务器协议中的命令数和服务器支持的 SQL 语句类型数计算的。
不应更改此变量,除非将其设置为 0 以禁用所有语句检测并保存与其关联的所有内存。将变量设置为默认值以外的非零值没有任何好处;特别是,大于默认值的值会导致分配比需要更多的内存。
performance_schema_max_table_handles命令行格式 --performance-schema-max-table-handles=#系统变量 performance_schema_max_table_handles范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)打开的表对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_table_instances命令行格式 --performance-schema-max-table-instances=#系统变量 performance_schema_max_table_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测表对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_thread_classes命令行格式 --performance-schema-max-thread-classes=#系统变量 performance_schema_max_thread_classes范围 全球的 动态的 不 类型 整数 默认值 50最小值 0最大值 256线程工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。
performance_schema_max_thread_instances命令行格式 --performance-schema-max-thread-instances=#系统变量 performance_schema_max_thread_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测线程对象的最大数量。该值控制
threads表的大小。如果超过此最大值以致无法检测线程,则性能模式会增加Performance_schema_thread_instances_lost状态变量。有关如何设置和使用此变量的信息,请参阅 第 22.7 节,“性能模式状态监控”。max_connections系统变量影响服务器中运行的线程数 。performance_schema_max_thread_instances影响这些正在运行的线程中有多少可以被检测。的默认值performance_schema_max_thread_instances根据 的值自动调整大小max_connections。performance_schema_session_connect_attrs_size命令行格式 --performance-schema-session-connect-attrs-size=#系统变量 performance_schema_session_connect_attrs_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 1048576单元 字节 为保存连接属性键值对而保留的每个线程的预分配内存量。如果客户端发送的连接属性数据的总大小大于此数量,则性能模式会截断属性数据,增加
Performance_schema_session_connect_attrs_lost状态变量,并向错误日志写入一条消息,指示如果log_warnings系统变量值更大则发生截断比零。的默认值
performance_schema_session_connect_attrs_size在服务器启动时自动调整。该值可能很小,因此如果发生截断(Performance_schema_session_connect_attrs_lost变为非零),您可能希望performance_schema_session_connect_attrs_size明确设置为更大的值。尽管最大允许
performance_schema_session_connect_attrs_size值为 1MB,但有效最大值为 64KB,因为服务器对其可接受的连接属性数据的总大小施加了 64KB 的限制。如果客户端尝试发送超过 64KB 的属性数据,服务器将拒绝连接。有关详细信息,请参阅 第 22.12.8 节,“性能模式连接属性表”。performance_schema_setup_actors_size命令行格式 --performance-schema-setup-actors-size=#系统变量 performance_schema_setup_actors_size范围 全球的 动态的 不 类型 整数 默认值 100最小值 0最大值 1048576表中的行数
setup_actors。performance_schema_setup_objects_size命令行格式 --performance-schema-setup-objects-size=#系统变量 performance_schema_setup_objects_size范围 全球的 动态的 不 类型 整数 默认值 100最小值 0最大值 1048576表中的行数
setup_objects。-
命令行格式 --performance-schema-users-size=#系统变量 performance_schema_users_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 1048576表中的行数
users。如果此变量为 0,则 Performance Schema 不会在users表中维护连接统计信息。