查看主机和会话信息
一、主机连接信息(host_summary)
mysql> select * from sys.host_summary \G;
*************************** 1. row ***************************
host: ip131
statements: 255
statement_latency: 1.23 m
statement_avg_latency: 289.51 ms
table_scans: 69
file_ios: 106581
file_io_latency: 37.22 s
current_connections: 2
total_connections: 4
unique_users: 3
current_memory: 0 bytes
total_memory_allocated: 0 bytes
输出项说明
# host :连接到 MySQL 实例的主机的 IP
# statements :主机 IP 执行总的 SQL 语句数量
# statement_latency :主机 IP 执行 SQL 语句消耗的总时间
# statement_avg_latency :主机的每个语句的平均等待时间。
# table_scans :主机的表扫描总数。
# file_ios :主机的文件I / O事件总数。
# file_io_latency :主机文件I / O事件的总等待时间。
# current_connections :主机的当前连接数。
# total_connections :主机的连接总数。
# unique_users :主机的独立用户数。
# current_memory :当前为主机分配的内存量。
# total_memory_allocated :主机分配的内存总量。
二、查看连接和会话相关信息(sys.session)
查询 sys.session可以得到会话的 ID 、连接用户信息、连接时间、查询影响行数、返回行数、最后执行 SQL 等信息。
mysql> select * from sys.session where conn_id=11 \G;
*************************** 1. row ***************************
thd_id: 36
conn_id: 11
user: root@localhost
db: test
command: Sleep
state: NULL
time: 1586
current_statement: update a1 set b=2222222222 where id=10001
statement_latency: NULL
progress: NULL
lock_latency: 124.00 us
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
last_statement: update a1 set b=2222222222 where id=10001
last_statement_latency: 16.69 m
current_memory: 0 bytes
last_wait: NULL
last_wait_latency: NULL
source: NULL
trx_latency: NULL
trx_state: NULL
trx_autocommit: NULL
pid: 7741
program_name: mysql
1 row in set (0.05 sec)