MySQL sys库常用的SQL命令整理
发布时间:2022-01-17 13:29:42 所属栏目:MySql教程 来源:互联网
导读:本篇内容主要讲解MySQL sys库常用的SQL命令整理,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习MySQL sys库常用的SQL命令整理吧! 查看当前连接情况: select host, current_connections,statements from sys.hos
本篇内容主要讲解“MySQL sys库常用的SQL命令整理”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL sys库常用的SQL命令整理”吧! 查看当前连接情况: select host, current_connections,statements from sys.host_summary; 查看当前正在执行的SQL: select conn_id, user, current_statement, last_statement from sys.session; 查看系统里执行最多的TOP 10 SQL: select * from sys.statement_analysis order by exec_count desc limit 10 G 查看系统里哪张表的IO最多: select * from sys.io_global_by_file_by_bytes limit 10; 查看系统里哪张表访问次数最多: select * from sys.statement_analysis order by exec_count desc limit 10 G 查看哪些语句延迟比较严重: select * from sys.statement_analysis order by avg_latency desc limit 10 G 查看系统里未使用过的索引: select * from sys.schema_unused_indexes; 查看系统里冗余的索引: select table_schema,table_name,redundant_index_name,redundant_index_columns,dominant_index_name,dominant_index_columns from sys.schema_redundant_indexes; 哪些SQL语句使用了磁盘临时表: select db, query, tmp_tables,tmp_disk_tables from sys.statement_analysis where tmp_tables>0 or tmp_disk_tables >0 order by(tmp_tables+tmp_disk_tables) desc limit 20; 查看哪张表占用了最多的buffer pool: select * from sys.innodb_buffer_stats_by_table order by pages desc limit 10 G 查看每个库占用多少buffer pool: select * from sys.innodb_buffer_stats_by_schema; 查看每个连接分配多少内存: select b.user, current_count_used,current_allocated, current_avg_alloc, current_max_alloc,total_allocated,current_statement from sys.memory_by_thread_by_current_bytes a,sys.session b where a.thread_id = b.thd_id; 查看MySQL内部的线程类型及数量: select user, count(*) from sys.processlist group by user; 查看表自增ID情况: select * from sys.schema_auto_increment_columns limit 10; 附:sys库视图和指标详解 视图 说明 host_summary,x $ host_summary 统计以主机为分组统计活动的语句,文件I / O,连接等信息 host_summary_by_file_io,x $ host_summary_by_file_io 文件IO host_summary_by_file_io_type,x $ host_summary_by_file_io_type 主机和事件类型的文件I / O 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_type 按照主机和SQL执行的语句信息 innodb_buffer_stats_by_schema,x $ innodb_buffer_stats_by_schema 按照架构统计InnoDB缓冲区信息 innodb_buffer_stats_by_table,x $ innodb_buffer_stats_by_table 按照schema和表统计InnoDB缓冲区信息 innodb_lock_waits,x $ innodb_lock_waits InnoDB锁锁信息 io_by_thread_by_latency,x $ io_by_thread_by_latency 线程消耗IO io_global_by_file_by_bytes,x $ io_global_by_file_by_bytes 文件IO消耗大小信息 io_global_by_file_by_latency,x $ io_global_by_file_by_latency 文件IO延迟信息 io_global_by_wait_by_bytes,x $ io_global_by_wait_by_bytes 按照大小(字节)的全局I / O消耗 io_global_by_wait_by_latency,x $ io_global_by_wait_by_latency IO消耗的延迟信息 latest_file_io,x $ latest_file_io 最近使用文件I / O信息 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 内存统计信息 指标说明 processlist,x $ processlist Processlist进程信息 ps_check_lost_instrumentation 丢失的性能模式工具的信息 schema_auto_increment_columns AUTO_INCREMENT自增长列信息 schema_index_statistics,x $ schema_index_statistics 索引统计信息 schema_object_overview 每个模式的对象类型 schema_redundant_indexes 重复/冗余的索引 schema_table_lock_waits,x $ schema_table_lock_waits 等待MDL的会话 schema_table_statistics,x $ schema_table_statistics 表统计信息 schema_table_statistics_with_buffer,x $ schema_table_statistics_with_buffer表统计信息,包含InnoDB缓冲池统计信息 schema_tables_with_full_table_scans,x $ schema_tables_with_full_table_scans全表访问的表 schema_unused_indexes 没有使用的索引 session,x $ session 用户会话的Processlis信息 session_ssl_status SSL连接信息 statement_analysis,x $ statement_analysis SQL语句汇总信息统计 statements_with_errors_or_warnings,x $ statements_with_errors_or_warnings 含有错误和警告的SQL statements_with_full_table_scans,x $ statements_with_full_table_scans 执行时候全表扫描的语句 statements_with_runtimes_in_95th_percentile,X $ statements_with_runtimes_in_95th_percentile平均运行时间很长的SQL statements_with_sorting,x $ statements_with_sorting 排序的SQL语句 statements_with_temp_tables,x $ statements_with_temp_tables 使用临时表的SQL玉溪 user_summary,x $ user_summary 用户语句和活动连接信息 user_summary_by_file_io,x $ user_summary_by_file_io 用户相关文件I / O信息 user_summary_by_file_io_type,x $ user_summary_by_file_io_type 用户相关文件FI / O类型信息 user_summary_by_stages,x $ user_summary_by_stages 用户阶段事件和延迟信息 user_summary_by_statement_latency,x $ user_summary_by_statement_latency 以统计的SQL语句信息 user_summary_by_statement_type,x $ user_summary_by_statement_type 按照用户和事件(事件)已执行的SQL语句信息 wa_ 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 按事件统计的事件信息 到此,相信大家对“MySQL sys库常用的SQL命令整理”有了更深的了解,不妨来实际操作一番吧! (编辑:重庆站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |