MySQL sys Schema
使用sys Schema的先决条件
使用sys Schema
sys Schema Progress Reporting
sys Schema Object Reference
MySQL 5.7.7及更高版本包括sys schema,这是一组帮助DBA和开发人员解释Performance schema收集的数据的对象。 sys schema对象可用于典型的调优和诊断用例。 此schema中的对象包括:
将Performance Schema数据汇总为更易于理解的形式的视图。
执行诸如 Performance Schema 配置和生成诊断报告等操作的存储过程。
存储函数,用于查询 Performance Schema 配置并提供格式化服务。
在新安装MySQL实例时,如果将mysqld与--initialize或--initialize-insecure选项一起使用,则在数据目录初始化期间默认安装sys schema。如果不需要,可以在初始化后手动删除sys schema。
在升级MySQL时,mysql_upgrade会安装sys schema(如果未安装),否则将其升级到当前版本。如果不想安装或升级,可以使用:mysql_upgrade选项--skip-sys-schema。
如果存在sys schema但没有version视图,mysql_upgrade会返回错误,前提是缺少此视图表示用户创建的sys schema。要在这种情况下进行升级,请先删除或重命名现有的sys schema。
从MySQL 5.7.9开始,sys schema对象的DEFINER为’mysql.sys’@’localhost’。 (在MySQL 5.7.9之前,DEFINER是’root’@’localhost’。)使用专用的mysql.sys帐户可以避免DBA重命名或删除root帐户时出现的问题。
sys Schema 视图
host_summary 与 x$host_summary host_summary_by_file_io 与 x$host_summary_by_file_iohost_summary_by_file_io_type 与 x$host_summary_by_file_io_type host_summary_by_stages 与 x$host_summary_by_stages host_summary_by_statement_latency 与 x$host_summary_by_statement_latency host_summary_by_statement_type 与 x$host_summary_by_statement_typeinnodb_buffer_stats_by_schema 与 x$innodb_buffer_stats_by_schema innodb_buffer_stats_by_table 与 x$innodb_buffer_stats_by_table innodb_lock_waits 与 x$innodb_lock_waits io_by_thread_by_latency 与 x$io_by_thread_by_latencyio_global_by_file_by_bytes 与 x$io_global_by_file_by_bytes io_global_by_file_by_latency 与 x$io_global_by_file_by_latency io_global_by_wait_by_bytes 与 x$io_global_by_wait_by_bytes io_global_by_wait_by_latency 与 x$io_global_by_wait_by_latency latest_file_io 与 x$latest_file_io memory_by_host_by_current_bytes 与 x$memory_by_host_by_current_bytes memory_by_thread_by_current_bytes 与 x$memory_by_thread_by_current_bytes memory_by_user_by_current_bytes 与 x$memory_by_user_by_current_bytes memory_global_by_current_bytes 与 x$memory_global_by_current_bytes memory_global_total 与 x$memory_global_total metrics processlist 与 x$processlist ps_check_lost_instrumentationschema_auto_increment_columnsschema_index_statistics 与 x$schema_index_statistics schema_object_overview schema_redundant_indexes 与 x$schema_flattened_keys schema_table_lock_waits 与 x$schema_table_lock_waits schema_table_statistics 与 x$schema_table_statistics schema_table_statistics_with_buffer 与 x$schema_table_statistics_with_buffer schema_tables_with_full_table_scans 与 x$schema_tables_with_full_table_scans schema_unused_indexes session 与 x$session session_ssl_status statement_analysis 与 x$statement_analysis statements_with_errors_or_warnings 与 x$statements_with_errors_or_warnings statements_with_full_table_scans 与 x$statements_with_full_table_scans statements_with_runtimes_in_95th_percentile 与 x$statements_with_runtimes_in_95th_percentilestatements_with_sorting 与 x$statements_with_sorting statements_with_temp_tables 与 x$statements_with_temp_tables user_summary 与 x$user_summary user_summary_by_file_io 与 x$user_summary_by_file_io user_summary_by_file_io_type 与 x$user_summary_by_file_io_type user_summary_by_stages 与 x$user_summary_by_stagesuser_summary_by_statement_latency 与 x$user_summary_by_statement_latency user_summary_by_statement_type 与 x$user_summary_by_statement_type version wait_classes_global_by_avg_latency 与 x$wait_classes_global_by_avg_latency wait_classes_global_by_latency 与 x$wait_classes_global_by_latency waits_by_host_by_latency 与 x$waits_by_host_by_latency waits_by_user_by_latency 与 x$waits_by_user_by_latency waits_global_by_latency 与 x$waits_global_by_latency
以下部分描述了sys schema视图。
sys模式包含许多视图,这些视图以各种方式汇总了Performance Schema表。 这些视图中的大多数成对出现,使得该对中的一个成员具有与另一个成员相同的名称,加上x$前缀。 例如,host_summary_by_file_io视图汇总了按主机分组的文件I/O,并显示从皮秒转换为更可读的值(带单位)的延迟;
| localhost | 67570 | 5.38 s |
x$host
_summary_by
_file_io视图汇总了相同的数据,但显示了未格式化的皮秒延迟:
| localhost | 67574 | 5380678125144 |
没有x$前缀的视图旨在提供更加用户友好且更易于阅读的输出。 带有x$前缀的视图以原始形式显示相同的值,更适合与对数据执行自己处理的其他工具一起使用。
没有x$前缀的视图在这些方面与相应的x$视图不同:
字节值使用format_bytes()以大小单位格式化。
使用format_time()以时间单位格式化时间值。
使用format_statement()将SQL语句截断为最大显示宽度。
使用format_path()缩短路径名。
转载于:https://www.cnblogs.com/wanbin/p/9514615.html