PROCESSLIST

PROCESSLISTSHOW PROCESSLIST 的功能一样,都是查看当前正在处理的请求。

PROCESSLIST 表比 SHOW PROCESSLIST 的结果多出下面几列:

  • MEM 列:MEM 显示正在处理的请求已使用的内存,单位是 byte。
  • TxnStart列:显示事务的开始时间
  1. USE information_schema;
  2. DESC processlist;
  1. +----------+---------------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +----------+---------------------+------+------+---------+-------+
  4. | ID | bigint(21) unsigned | NO | | 0 | |
  5. | USER | varchar(16) | NO | | | |
  6. | HOST | varchar(64) | NO | | | |
  7. | DB | varchar(64) | YES | | NULL | |
  8. | COMMAND | varchar(16) | NO | | | |
  9. | TIME | int(7) | NO | | 0 | |
  10. | STATE | varchar(7) | YES | | NULL | |
  11. | INFO | binary(512) | YES | | NULL | |
  12. | MEM | bigint(21) unsigned | YES | | NULL | |
  13. | TxnStart | varchar(64) | NO | | | |
  14. +----------+---------------------+------+------+---------+-------+
  15. 10 rows in set (0.00 sec)
  1. SELECT * FROM processlist\G
  1. *************************** 1. row ***************************
  2. ID: 16
  3. USER: root
  4. HOST: 127.0.0.1
  5. DB: information_schema
  6. COMMAND: Query
  7. TIME: 0
  8. STATE: autocommit
  9. INFO: SELECT * FROM processlist
  10. MEM: 0
  11. TxnStart:
  12. 1 row in set (0.00 sec)

PROCESSLIST 表各列的含义如下:

  • ID:客户连接 ID。
  • USER:执行当前 PROCESS 的用户名。
  • HOST:客户连接的地址。
  • DB:当前连接的默认数据库名。
  • COMMAND:当前 PROCESS 执行的命令类型。
  • TIME:当前 PROCESS 的已经执行的时间,单位是秒。
  • STATE:当前连接的状态。
  • INFO:正在处理的请求语句。
  • MEM:正在处理的请求已使用的内存,单位是 byte。
  • TxnStart列:显示事务的开始时间

CLUSTER_PROCESSLIST

CLUSTER_PROCESSLISTPROCESSLIST 对应的集群系统表,用于查询集群中所有 TiDB 节点的 PROCESSLIST 信息。CLUSTER_PROCESSLIST 表结构上比 PROCESSLIST 多一列 INSTANCE,表示该行数据来自的 TiDB 节点地址。

  1. SELECT * FROM cluster_processlist;
  1. +-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+
  2. | INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart |
  3. +-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+
  4. | 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) |
  5. | 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) |
  6. | 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) |
  7. | 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) |
  8. | 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) |
  9. +-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+