How to customize `show processlist` in MySQL?

MySQLMySQLi Database

The show processlist can be customized with the help of information_schema.processlist. In newer MySQL version, the “show processlist” command can be used in “information_schema”.

The “information_schema.processlist” has been added in MySQL version 5.1.7. Firstly, let us check the MySQL version. The query to check the version is as follows −

mysql> select version();

The following is the output.

+-----------+
| version() |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)

Now ,we can use the customized “show processlist”.The query is as follows.

mysql> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;

The following is the output.

+----+-----------------+-----------------+----------+---------+-------+------------------------+----------------------------------------------+
| ID | USER            | HOST            | DB       | COMMAND | TIME  | STATE                  | INFO                                         |
+----+-----------------+-----------------+----------+---------+-------+------------------------+----------------------------------------------+
|  8 | root            | localhost:50599 | business | Query   |     0 | executing              | SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST |
|  9 | root            | localhost:53404 | NULL     | Sleep   |   132 |                        | NULL                                         |
|  4 | event_scheduler | localhost       | NULL     | Daemon  | 71998 | Waiting on empty queue | NULL                                         |
+----+-----------------+-----------------+----------+---------+-------+------------------------+----------------------------------------------+
3 rows in set (0.06 sec)
raja
Published on 30-Nov-2018 11:01:11
Advertisements