Toshimaru's Blog

Filter MySQL processlist

You can see MySQL processes by show processlist.

show processlist;
-- Or
show full processlist;

But, it can’t be filtered. If you’d like to retrieve processes like usual SQL syntax, it can be replaced with:

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;

Now, you can filter process with WHERE clause.

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE 
    DB = 'development' AND 
    USER = 'myuser';

Order by Time

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE 
    DB = 'development' AND 
    USER = 'myuser'
ORDER BY TIME DESC;

See also