Information Schema Examples
suggest changeProcesslist
This lists threads. ORDER BY INFO sorts by statement text, not by “active then sleeping.” Sleeping threads usually have INFO NULL. TIME is how long the thread has been in its current state, in seconds.
SELECT * FROM information_schema.PROCESSLIST ORDER BY INFO DESC, TIME DESC;
The same list, with the time converted to minutes and hours:
SELECT ID, USER, HOST, DB, COMMAND,
TIME as time_seconds,
ROUND(TIME / 60, 2) as time_minutes,
ROUND(TIME / 60 / 60, 2) as time_hours,
STATE, INFO
FROM information_schema.PROCESSLIST ORDER BY INFO DESC, TIME DESC;
Stored Procedure Searching
Search stored routines for a word. ROUTINES includes procedures and functions. The definition is matched as text, so this can be slow on a server with many routines.
SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%word%';
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents