您当前的位置:首页 > 计算机 > 软件应用 > 数据库 > MySQL

MySQL 如何使用show processlist进行过滤

时间:09-30来源:作者:点击数:
城东书院 www.cdsy.xyz

在使用show processlist的时候,直接使用会显示很多的内容,无法很快找到需要的信息。

如何过滤操作呢?

其实,show processlist展示的内容是从information_schema.processlist数据表查询得到。

数据表information_schema.processlist各字段如下:

mysql> desc information_schema.processlist;
+---------+---------------------+------+-----+---------+-------+
| Field   | Type                | Null | Key | Default | Extra |
+---------+---------------------+------+-----+---------+-------+
| ID      | bigint(21) unsigned | NO   |     | 0       |       |
| USER    | varchar(32)         | NO   |     |         |       |
| HOST    | varchar(64)         | NO   |     |         |       |
| DB      | varchar(64)         | YES  |     | NULL    |       |
| COMMAND | varchar(16)         | NO   |     |         |       |
| TIME    | int(7)              | NO   |     | 0       |       |
| STATE   | varchar(64)         | YES  |     | NULL    |       |
| INFO    | longtext            | YES  |     | NULL    |       |
+---------+---------------------+------+-----+---------+-------+
8 rows in set (0.04 sec)

所以可以使用SQL语句的条件查询进行过滤,例如:

>select * from information_schema.processlist where Host like '10.26.201.199%';
+---------+-------------+---------------------+------+---------+------+-------+------+---------+-----------+---------------+
| ID      | USER        | HOST                | DB   | COMMAND | TIME | STATE | INFO | TIME_MS | ROWS_SENT | ROWS_EXAMINED |
+---------+-------------+---------------------+------+---------+------+-------+------+---------+-----------+---------------+
|  315835 | ora_manager | 10.26.201.199:45028 | NULL | Sleep   | 2796 |       | NULL | 2795673 |         1 |             0 |
| 1354509 | ora_manager | 10.26.201.199:53340 | NULL | Sleep   |  976 |       | NULL |  975677 |         1 |             0 |
|  240640 | ora_manager | 10.26.201.199:45802 | NULL | Sleep   |    4 |       | NULL |    3684 |         1 |             0 |
| 1354510 | ora_manager | 10.26.201.199:53342 | NULL | Sleep   |  976 |       | NULL |  975678 |         1 |             0 |
|  240641 | ora_manager | 10.26.201.199:45810 | NULL | Sleep   |    4 |       | NULL |    3687 |         1 |             0 |
|  315836 | ora_manager | 10.26.201.199:45032 | NULL | Sleep   | 2796 |       | NULL | 2795672 |         1 |             0 |
| 1354511 | ora_manager | 10.26.201.199:53344 | NULL | Sleep   |  976 |       | NULL |  975678 |         1 |          1103 |
|  315837 | ora_manager | 10.26.201.199:45030 | NULL | Sleep   | 2796 |       | NULL | 2795674 |         1 |          1103 |
|  240642 | ora_manager | 10.26.201.199:45812 | NULL | Sleep   |    4 |       | NULL |    3687 |         1 |          1103 |
+---------+-------------+---------------------+------+---------+------+-------+------+---------+-----------+---------------+
9 rows in set (0.00 sec)
城东书院 www.cdsy.xyz
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐