MySQL系统管理辅助库 ## 基本信息 - 数据库名称: sys - 作用: 提供performance_schema的友好视图 - 特性: 只读视图和存储过程 - MySQL版本: 5.7+ ## 主要视图 1. schema_table_statistics - 表统计 - table_schema - table_name - rows_fetched - io_read_requests 2. statement_analysis - SQL语句分析 - query - exec_count - avg_latency - rows_sent 3. user_summary - 用户活动汇总 - user - statements - statement_latency - file_ios 4. memory_by_host_by_current_bytes - 内存使用 - host - current_count_used - current_allocated ## 常用查询 1. 查看未使用索引 SELECT * FROM schema_unused_indexes; 2. 查看内存使用TOP10 SELECT * FROM memory_global_by_current_bytes LIMIT 10; 3. 查看连接来源 SELECT * FROM host_summary; ## 注意事项 1. 基于performance_schema数据 2. 需要performance_schema启用 3. 视图数据非实时