利用sys库进行IO信息诊断
1、 table 相关
1.1 查询表的IO请求数量
mysql> select concat_ws('.',table_schema,table_name) 'table',
io_read_requests,
io_write_requests,
io_misc_requests
from sys.schema_table_statistics_with_bufferG
*************************** 1. row ***************************
table: universe.u_delay # 表名
io_read_requests: 11 # 读请求数量
io_write_requests: 4 # 写请求数量
io_misc_requests: 15 # IO总请求数量
1.2 查询表的IO请求字节数
mysql> select concat_ws('.',table_schema,table_name) 'table',
io_read,
io_write
from sys.schema_table_statistics_with_bufferG
*************************** 1. row ***************************
table: universe.u_delay # 表名
io_read: 113.35 KiB # 读字节数
io_write: 64.00 KiB # 写字节数
1.3 查询表的IO请求延迟时间
mysql> select concat_ws('.',table_schema,table_name) 'table',
io_read_latency,
io_write_latency,
io_misc_latency
from sys.schema_table_statistics_with_bufferG
*************************** 1. row ***************************
table: universe.u_delay # 表名
io_read_latency: 2.26 ms # 读等待时间
io_write_latency: 161.02 us # 写等待时间
io_misc_latency: 4.36 ms # IO总等待时间
2、 server 相关
2.1 查询按主机和事件的IO等待时间(表物理IO)
mysql> select * from sys.host_summary_by_file_io_type limit 5G
*************************** 1. row ***************************
host: 10.186.64.134 # 来源主机
event_name: wait/io/file/innodb/innodb_log_file # io事件名称
total: 802 # 事件总数
total_latency: 307.34 ms # io事件总等待时间
max_latency: 7.10 ms # 该主机io事务中最大等待时间
2.2 查询按主机分组IO请求次数及延迟时间
mysql> select * from sys.host_summary_by_file_io limit 10G
*************************** 1. row ***************************
host: 127.0.0.1 # 主机
ios: 7073593 # io事件总数
io_latency: 20.69 m # io等待总时间
3、 data file 相关
3.1 查询按文件分组显示对应的IO字节数
mysql> select * from sys.io_global_by_file_by_bytes limit 10G
*************************** 1. row ***************************
file: @@innodb_log_group_home_dir/ib_logfile0 # 文件路径名
count_read: 7 # i/o 事务读的次数
total_read: 68.50 KiB # i/o 事务读总等待时间
avg_read: 9.79 KiB # i/o 事务读平均字节数
count_write: 1047151 # i/o 事务写文件次数
total_written: 1.12 GiB # i/o 事务写文件总字节
avg_write: 1.12 KiB # i/o 事务写文件平均字节
total: 1.12 GiB # i/o 事务的总字节数
write_pct: 99.99 # i/o 事务写占总字节数百分比
3.2 查询按文件分组显示对应的IO等待时间
mysql> select * from sys.io_global_by_file_by_latency limit 10G
*************************** 1. row ***************************
file: @@innodb_log_group_home_dir/ib_logfile0 # 文件路径名
total: 2096224 # i/o 事务的总数量
total_latency: 11.96 m # i/o 事务总等待时间
count_read: 7 # i/o 事务读文件次数
read_latency: 1.47 ms # i/o 事务读等待时间
count_write: 1048107 # i/o 事务写文件次数
write_latency: 30.68 s # i/o 事务写等待时间
count_misc: 1048110 # i/o 事务读写文件次数
misc_latency: 11.45 m # i/o 事务总等待时间
4、 threads 相关
4.1 线程对应IO的消耗及等待时间
mysql> select * from sys.io_by_thread_by_latency limit 10G
*************************** 1. row ***************************
user: srv_master_thread # 当前用户对应的后台线程线程的名称
total: 1003296 # io事件的总数
total_latency: 6.21 m # io事件的总延迟数
min_latency: 7.00 us # io事件的最小延迟
avg_latency: 210.84 us # 平均io延迟
max_latency: 23.35 ms # 最大io延迟
thread_id: 27 # 线程id
processlist_id: NULL # 对于当前线程就是此时的id对于后台就是null