As @Hariraman Radhakrishnan answered, the SHOW PROCESSLIST
command cannot be modified.
However, from reading his link, the SHOW PROCESSLIST
actually reads from information_schema.processlist
This means you can perform a normal query against information_schema.processlist
like this:
SELECT *
FROM information_schema.processlist
WHERE TIME > 30
If you look at https://dev.mysql.com/doc/refman/8.0/en/processlist-table.html, you can see what each column means.
I have written the query to select all processes that have been running for more than 30 seconds, but that might also just be a sleeping connection, for example a program that connects at the beginning, and then keeps the connection alive until you close the program again.
This would mean that the process can run for minutes, hours or days, but will have COMMAND = 'Sleep'
most of the time.
If you only want to see long running queries, you should update your queries to:
SELECT * FROM information_schema.processlist WHERE COMMAND != 'Sleep' AND TIME > 30;
TIME is reset when the state changes
From the docs: "The time in seconds that the thread has been in its current state.")