性能模式实现了几个提供配置信息的系统变量:
mysql> SHOW VARIABLES LIKE 'perf%';
+----------------------------------------------------------+-------+
| Variable_name | Value |
+----------------------------------------------------------+-------+
| performance_schema | ON |
| performance_schema_accounts_size | -1 |
| performance_schema_digests_size | 10000 |
| 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_transactions_history_long_size | 10000 |
| performance_schema_events_transactions_history_size | 10 |
| performance_schema_events_waits_history_long_size | 10000 |
| performance_schema_events_waits_history_size | 10 |
| performance_schema_hosts_size | -1 |
| performance_schema_max_cond_classes | 80 |
| performance_schema_max_cond_instances | -1 |
| performance_schema_max_digest_length | 1024 |
| performance_schema_max_file_classes | 50 |
| performance_schema_max_file_handles | 32768 |
| performance_schema_max_file_instances | -1 |
| performance_schema_max_index_stat | -1 |
| performance_schema_max_memory_classes | 320 |
| performance_schema_max_metadata_locks | -1 |
| performance_schema_max_mutex_classes | 200 |
| performance_schema_max_mutex_instances | -1 |
| performance_schema_max_prepared_statements_instances | -1 |
| performance_schema_max_program_instances | -1 |
| performance_schema_max_rwlock_classes | 40 |
| performance_schema_max_rwlock_instances | -1 |
| performance_schema_max_socket_classes | 10 |
| performance_schema_max_socket_instances | -1 |
| performance_schema_max_sql_text_length | 1024 |
| performance_schema_max_stage_classes | 150 |
| performance_schema_max_statement_classes | 192 |
| performance_schema_max_statement_stack | 10 |
| performance_schema_max_table_handles | -1 |
| performance_schema_max_table_instances | -1 |
| performance_schema_max_table_lock_stat | -1 |
| performance_schema_max_thread_classes | 50 |
| performance_schema_max_thread_instances | -1 |
| performance_schema_session_connect_attrs_size | 512 |
| performance_schema_setup_actors_size | -1 |
| performance_schema_setup_objects_size | -1 |
| performance_schema_users_size | -1 |
+----------------------------------------------------------+-------+Performance Schema 系统变量可以在服务器启动时在命令行或选项文件中设置,许多可以在运行时设置。请参阅 第 25.13 节,“性能模式选项和变量参考”。
如果未明确设置,性能模式会在服务器启动时自动调整其几个参数的值。有关详细信息,请参阅 第 25.3 节,“性能模式启动配置”。
Performance Schema 系统变量具有以下含义:
-
命令行格式 --performance-schema[={OFF|ON}]系统变量 performance_schema范围 全球的 动态的 不 类型 布尔值 默认值 ON该变量的值为
ONorOFF,表示性能模式是否启用。默认情况下,该值为ON。在服务器启动时,您可以指定此变量不带任何值或值为ON或 1 以启用它,或者指定此变量的值为OFF或 0 以禁用它。即使禁用性能模式,它也会继续填充
global_variables、session_variables、global_status和session_status表。根据系统变量 的设置,这是必要的,以允许 从这些表中提取SHOW VARIABLES和 语句的结果。SHOW STATUSshow_compatibiliy_56 performance_schema_accounts_size命令行格式 --performance-schema-accounts-size=#系统变量 performance_schema_accounts_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
accounts。如果该变量为 0,则 Performance Schema 不维护表中的连接统计accounts信息或表中的状态变量信息status_by_account。performance_schema_digests_size命令行格式 --performance-schema-digests-size=#系统变量 performance_schema_digests_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的最大行数
events_statements_summary_by_digest。如果超过此最大值以致无法检测摘要,则性能模式会增加Performance_schema_digest_lost状态变量。有关语句摘要的更多信息,请参阅 第 25.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_transactions_history_long_size命令行格式 --performance-schema-events-transactions-history-long-size=#系统变量 performance_schema_events_transactions_history_long_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
events_transactions_history_long。performance_schema_events_transactions_history_size命令行格式 --performance-schema-events-transactions-history-size=#系统变量 performance_schema_events_transactions_history_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1024表中每个线程的行数
events_transactions_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信息或表中的状态变量信息status_by_host。 performance_schema_max_cond_classes命令行格式 --performance-schema-max-cond-classes=#系统变量 performance_schema_max_cond_classes范围 全球的 动态的 不 类型 整数 默认值 80最小值 0最大值 256条件工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_cond_instances命令行格式 --performance-schema-max-cond-instances=#系统变量 performance_schema_max_cond_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测条件对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_digest_length命令行格式 --performance-schema-max-digest-length=#系统变量 performance_schema_max_digest_length范围 全球的 动态的 不 类型 整数 默认值 1024最小值 0最大值 1048576单元 字节 每个语句保留的最大内存字节数,用于计算性能模式中的规范化语句摘要值。该变量与
max_digest_length; 请参阅第 5.1.7 节“服务器系统变量”中对该变量的描述 。有关语句摘要的更多信息,包括有关内存使用的注意事项,请参阅 第 25.10 节,“性能模式语句摘要”。
performance_schema_max_file_classes命令行格式 --performance-schema-max-file-classes=#系统变量 performance_schema_max_file_classes范围 全球的 动态的 不 类型 整数 默认值 80最小值 0最大值 256文件工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_file_handles命令行格式 --performance-schema-max-file-handles=#系统变量 performance_schema_max_file_handles范围 全球的 动态的 不 类型 整数 默认值 32768最小值 0最大值 1048576打开的文件对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.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(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测文件对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_index_stat命令行格式 --performance-schema-max-index-stat=#系统变量 performance_schema_max_index_stat范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576性能模式维护统计信息的最大索引数。如果超过此最大值以致索引统计信息丢失,则性能模式会增加
Performance_schema_index_stat_lost状态变量。默认值是使用 的值自动调整大小的performance_schema_max_table_instances。performance_schema_max_memory_classes命令行格式 --performance-schema-max-memory-classes=#系统变量 performance_schema_max_memory_classes范围 全球的 动态的 不 类型 整数 默认值 320最小值 0最大值 1024记忆仪器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_metadata_locks命令行格式 --performance-schema-max-metadata-locks=#系统变量 performance_schema_max_metadata_locks范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 10485760元数据锁定工具的最大数量。该值控制
metadata_locks表的大小。如果超过此最大值以致无法检测元数据锁,则性能模式会增加Performance_schema_metadata_lock_lost状态变量。performance_schema_max_mutex_classes命令行格式 --performance-schema-max-mutex-classes=#系统变量 performance_schema_max_mutex_classes范围 全球的 动态的 不 类型 整数 默认值 200最小值 0最大值 256互斥仪器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_mutex_instances命令行格式 --performance-schema-max-mutex-instances=#系统变量 performance_schema_max_mutex_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 104857600检测互斥对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_prepared_statements_instances命令行格式 --performance-schema-max-prepared-statements-instances=#系统变量 performance_schema_max_prepared_statements_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 4194304表中的最大行数
prepared_statements_instances。如果超过此最大值以致无法检测准备好的语句,则性能模式会增加Performance_schema_prepared_statements_lost状态变量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。该变量的默认值是根据
max_prepared_stmt_count系统变量的值自动调整大小的。performance_schema_max_rwlock_classes命令行格式 --performance-schema-max-rwlock-classes=#系统变量 performance_schema_max_rwlock_classes范围 全球的 动态的 不 类型 整数 默认值 (≥ 5.7.25) 50默认值(≤ 5.7.24) 40最小值 0最大值 256rwlock 仪器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_program_instances命令行格式 --performance-schema-max-program-instances=#系统变量 performance_schema_max_program_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576性能模式维护统计信息的最大存储程序数。如果超过这个最大值,性能模式会增加
Performance_schema_program_lost状态变量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。performance_schema_max_rwlock_instances命令行格式 --performance-schema-max-rwlock-instances=#系统变量 performance_schema_max_rwlock_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 104857600检测的 rwlock 对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_socket_classes命令行格式 --performance-schema-max-socket-classes=#系统变量 performance_schema_max_socket_classes范围 全球的 动态的 不 类型 整数 默认值 10最小值 0最大值 256套接字工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_socket_instances命令行格式 --performance-schema-max-socket-instances=#系统变量 performance_schema_max_socket_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测套接字对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_sql_text_length命令行格式 --performance-schema-max-sql-text-length=#系统变量 performance_schema_max_sql_text_length范围 全球的 动态的 不 类型 整数 默认值 1024最小值 0最大值 1048576单元 字节 、 和 语句事件表的
SQL_TEXT列中 用于存储 SQL 语句的最大字节数。超出的任何字节 都将被丢弃,并且不会出现在 列中。只有在该列中无法区分许多初始字节之后才不同的语句。events_statements_currentevents_statements_historyevents_statements_history_longperformance_schema_max_sql_text_lengthSQL_TEXT减小该
performance_schema_max_sql_text_length值会减少内存使用,但如果它们仅在末尾不同,则会导致更多语句变得无法区分。增加该值会增加内存使用,但允许区分更长的语句。performance_schema_max_stage_classes命令行格式 --performance-schema-max-stage-classes=#系统变量 performance_schema_max_stage_classes范围 全球的 动态的 不 类型 整数 默认值 150最小值 0最大值 256舞台乐器的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_statement_classes命令行格式 --performance-schema-max-statement-classes=#系统变量 performance_schema_max_statement_classes范围 全球的 动态的 不 类型 整数 最小值 0最大值 256语句工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
默认值是在服务器构建时根据客户端/服务器协议中的命令数和服务器支持的 SQL 语句类型数计算的。
不应更改此变量,除非将其设置为 0 以禁用所有语句检测并保存与其关联的所有内存。将变量设置为默认值以外的非零值没有任何好处;特别是,大于默认值的值会导致分配比需要更多的内存。
performance_schema_max_statement_stack命令行格式 --performance-schema-max-statement-stack=#系统变量 performance_schema_max_statement_stack范围 全球的 动态的 不 类型 整数 默认值 10最小值 1最大值 256性能模式维护统计信息的嵌套存储程序调用的最大深度。当超过这个最大值时,性能模式会
Performance_schema_nested_statement_lost为每个执行的存储程序语句增加状态变量。performance_schema_max_table_handles命令行格式 --performance-schema-max-table-handles=#系统变量 performance_schema_max_table_handles范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576打开的表对象的最大数量。该值控制
table_handles表的大小。如果超过此最大值以致无法检测表句柄,则性能模式会增加Performance_schema_table_handles_lost状态变量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。performance_schema_max_table_instances命令行格式 --performance-schema-max-table-instances=#系统变量 performance_schema_max_table_instances范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576检测表对象的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。
performance_schema_max_table_lock_stat命令行格式 --performance-schema-max-table-lock-stat=#系统变量 performance_schema_max_table_lock_stat范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动调整大小;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576Performance Schema 维护锁统计信息的最大表数。如果超过此最大值以致表锁统计信息丢失,则性能模式会增加
Performance_schema_table_lock_stat_lost状态变量。performance_schema_max_thread_classes命令行格式 --performance-schema-max-thread-classes=#系统变量 performance_schema_max_thread_classes范围 全球的 动态的 不 类型 整数 默认值 50最小值 0最大值 256线程工具的最大数量。有关如何设置和使用此变量的信息,请参阅 第 25.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状态变量。有关如何设置和使用此变量的信息,请参阅 第 25.7 节,“性能模式状态监控”。max_connections系统变量会影响服务器中可以运行的线程数 。performance_schema_max_thread_instances影响这些正在运行的线程中有多少可以被检测。variables_by_thread和 表仅包含有关前台线程 的status_by_thread系统和状态变量信息。如果不是所有线程都由性能模式检测,则该表可能会丢失一些行。在这种情况下,Performance_schema_thread_instances_lost状态变量大于零。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_error_verbosity系统变量值更大则发生截断比 1。的默认值
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 的属性数据,服务器将拒绝连接。有关详细信息,请参阅 第 25.12.9 节,“性能模式连接属性表”。performance_schema_setup_actors_size命令行格式 --performance-schema-setup-actors-size=#系统变量 performance_schema_setup_actors_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动调整大小;不要分配此文字值)最大值 1048576表中的行数
setup_actors。performance_schema_setup_objects_size命令行格式 --performance-schema-setup-objects-size=#系统变量 performance_schema_setup_objects_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
setup_objects。performance_schema_show_processlist命令行格式 --performance-schema-show-processlist[={OFF|ON}]介绍 5.7.39 系统变量 performance_schema_show_processlist范围 全球的 动态的 是的 类型 布尔值 默认值 OFF该
SHOW PROCESSLIST语句通过从所有活动线程收集线程数据来提供进程信息。该performance_schema_show_processlist变量决定SHOW PROCESSLIST使用哪个实现:默认实现在线程管理器中遍历活动线程,同时持有全局互斥锁。这会对性能产生负面影响,尤其是在繁忙的系统上。
替代
SHOW PROCESSLIST实现基于 Performance Schemaprocesslist表。此实现从性能模式而不是线程管理器查询活动线程数据,并且不需要互斥体。
要启用替代实现,请启用
performance_schema_show_processlist系统变量。为确保默认和替代实现产生相同的信息,必须满足某些配置要求;参见 第 25.12.16.3 节,“进程列表”。-
命令行格式 --performance-schema-users-size=#系统变量 performance_schema_users_size范围 全球的 动态的 不 类型 整数 默认值 -1(表示自动缩放;不要分配此文字值)最小值 -1(表示自动缩放;不要分配此文字值)最大值 1048576表中的行数
users。如果该变量为 0,则 Performance Schema 不维护表中的连接统计users信息或表中的状态变量信息status_by_user。