Menu

Toshimaru's Blog

Filter MySQL processlist

You can see MySQL processes by querying show processlist.

show processlist;
-- or
show full processlist;

However, 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 = 'your_database_name' AND
    USER = 'username_runnning_query';

Order by Time

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

See also

Load more