MySQL 5.7新增sys.session表查看系统运行状态
2016-04-26 15:34
537 查看
在MySQL 5.6以前,我们通过show processlist\G命令查看系统中正在运行的所有进程,从5.7开始,我们又可以通过sys.session表来查看系统正在运行的所有进程,而且该表中的记录相对processlist比较完善:
mysql>
SELECT * from sys.session\G
*************************** 1. row ***************************
thd_id: 29
conn_id: 4
user: root@localhost
db: test
command: Query
state: alter table (read PK and internal sort)
time: 6
current_statement: ALTER TABLE b add index(b)
statement_latency: 5.78 s
progress: 19.19
lock_latency: 203.70 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
last_statement: NULL
last_statement_latency: NULL
current_memory: 4.85 MiB
last_wait: wait/io/file/innodb/innodb_data_file
last_wait_latency: Still Waiting
source: fil0fil.cc:5623
trx_latency: 5.68 s
trx_state: ACTIVE
trx_autocommit: YES
pid: 23988
program_name: mysql
*************************** 2. row ***************************
thd_id: 28
conn_id: 3
user: root@localhost
db: test
command: Query
state: Sending data
time: 0
current_statement: insert into a select null, repeat('b', 255) from a
statement_latency: 303.54 ms
progress: NULL
lock_latency: 291.00 us
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 1
tmp_disk_tables: 0
full_scan: NO
last_statement: NULL
last_statement_latency: NULL
current_memory: 1.43 MiB
last_wait: wait/io/table/sql/handler
last_wait_latency: Still Waiting
source: handler.cc:3056
trx_latency: 410.06 ms
trx_state: ACTIVE
trx_autocommit: YES
pid: 23969
program_name: mysql
*************************** 3. row ***************************
thd_id: 27
conn_id: 2
user: root@localhost
db: mysql
command: Query
state: Sending data
time: 0
current_statement: SELECT * from sys.session
statement_latency: 23.01 ms
progress: NULL
lock_latency: 10.02 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 4
tmp_disk_tables: 1
full_scan: YES
last_statement: NULL
last_statement_latency: NULL
current_memory: 3.25 MiB
last_wait: wait/synch/mutex/innodb/file_format_max_mutex
last_wait_latency: 31.69 ns
source: trx0sys.cc:781
trx_latency: 4.94 m
trx_state: ACTIVE
trx_autocommit: NO
pid: 23950
program_name: mysql
3 rows in set (0.20 sec)
我们从第1行的输出可以看到,当前运行ALTER TABLE命令给一张表添加索引,还能读出目前该语句的执行阶段(目前正在读PK和进行内部排序),并能显示该命令完成的进度(19%),还包括当前执行的时间(5.78s)。
我们从第2行的输出可以看到,当前在执行INSERT操作,这是一个自动提交的事务,已经运行了410.06毫秒,我们甚至可以从中读到,需要一个临时表来执行该语句。
我们从第3行的输出可以看到,从执行SELECT * FROM sys.session开始到现在有一个事务已经持续了4.94分钟。
从上可见,我们通过SELECT * FROM sys.session可以获得更多的信息。尝试熟悉并习惯使用SELECT * FROM sys.session吧!
更多精彩MySQL内容 请关注我:
mysql>
SELECT * from sys.session\G
*************************** 1. row ***************************
thd_id: 29
conn_id: 4
user: root@localhost
db: test
command: Query
state: alter table (read PK and internal sort)
time: 6
current_statement: ALTER TABLE b add index(b)
statement_latency: 5.78 s
progress: 19.19
lock_latency: 203.70 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
last_statement: NULL
last_statement_latency: NULL
current_memory: 4.85 MiB
last_wait: wait/io/file/innodb/innodb_data_file
last_wait_latency: Still Waiting
source: fil0fil.cc:5623
trx_latency: 5.68 s
trx_state: ACTIVE
trx_autocommit: YES
pid: 23988
program_name: mysql
*************************** 2. row ***************************
thd_id: 28
conn_id: 3
user: root@localhost
db: test
command: Query
state: Sending data
time: 0
current_statement: insert into a select null, repeat('b', 255) from a
statement_latency: 303.54 ms
progress: NULL
lock_latency: 291.00 us
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 1
tmp_disk_tables: 0
full_scan: NO
last_statement: NULL
last_statement_latency: NULL
current_memory: 1.43 MiB
last_wait: wait/io/table/sql/handler
last_wait_latency: Still Waiting
source: handler.cc:3056
trx_latency: 410.06 ms
trx_state: ACTIVE
trx_autocommit: YES
pid: 23969
program_name: mysql
*************************** 3. row ***************************
thd_id: 27
conn_id: 2
user: root@localhost
db: mysql
command: Query
state: Sending data
time: 0
current_statement: SELECT * from sys.session
statement_latency: 23.01 ms
progress: NULL
lock_latency: 10.02 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 4
tmp_disk_tables: 1
full_scan: YES
last_statement: NULL
last_statement_latency: NULL
current_memory: 3.25 MiB
last_wait: wait/synch/mutex/innodb/file_format_max_mutex
last_wait_latency: 31.69 ns
source: trx0sys.cc:781
trx_latency: 4.94 m
trx_state: ACTIVE
trx_autocommit: NO
pid: 23950
program_name: mysql
3 rows in set (0.20 sec)
我们从第1行的输出可以看到,当前运行ALTER TABLE命令给一张表添加索引,还能读出目前该语句的执行阶段(目前正在读PK和进行内部排序),并能显示该命令完成的进度(19%),还包括当前执行的时间(5.78s)。
我们从第2行的输出可以看到,当前在执行INSERT操作,这是一个自动提交的事务,已经运行了410.06毫秒,我们甚至可以从中读到,需要一个临时表来执行该语句。
我们从第3行的输出可以看到,从执行SELECT * FROM sys.session开始到现在有一个事务已经持续了4.94分钟。
从上可见,我们通过SELECT * FROM sys.session可以获得更多的信息。尝试熟悉并习惯使用SELECT * FROM sys.session吧!
更多精彩MySQL内容 请关注我:
相关文章推荐
- 安装mysql Install/Remove of the Service Denied!错误的解决办法
- mysql的基本操作
- 解决mysql 1040错误Too many connections的方法
- 未能加载文件或程序集“MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d”或它的某一个依赖项...
- MySQL 入门教程
- XtraBackup/innobackupex 远程备份MySQL
- MYSQL之hex()函数查看表的一字段值的编码值
- 如何配置全世界最小的 MySQL 服务器
- mysql用存储过程插入百万条数据, 及查询优化
- mysql数据库配置主从同步
- R中mysql数据库datetime格式查询
- MySql 安装报错 :Last Error:Unable to update security. Access denied for user 'root'@'localhost'(using pa
- mysql 分表与分区
- MySQL函数
- 解析MySQL权限表
- mysql 索引介绍
- navicat 连接mysql报错 1129 host‘192.168.31.242’is blocked解决办法 --谷营中西软件科技园
- mysql 条件拼装
- mysql 条件拼装
- Mysql-5.7.11-winx64安装步骤