how to customize show processlist in mysql?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
SHOW PROCESSLIST is useful for a quick look at what MySQL is doing, but it is not a customizable report writer. If you want filtering, sorting, extra columns, or reusable output, the practical answer is to query the underlying process information tables and views instead of trying to change the SHOW PROCESSLIST statement itself.
What SHOW PROCESSLIST Can and Cannot Do
SHOW PROCESSLIST and SHOW FULL PROCESSLIST give you a snapshot of current sessions. That is enough for quick triage, but the format is fixed.
You cannot tell that statement to hide sleeping sessions, sort by runtime, or add CPU and lock latency columns. Current MySQL documentation also recommends the Performance Schema implementation rather than relying on the older INFORMATION_SCHEMA.PROCESSLIST path, which is deprecated in modern MySQL releases.
So the real customization path is:
- use
sys.processlistfor a cleaner high-level view - use
performance_schematables when you need more detail - create your own query or view for the exact output you want
Using sys.processlist for Better Filtering
If the sys schema is installed, sys.processlist is usually the best starting point. The MySQL 8.4 reference manual describes it as more complete than SHOW PROCESSLIST and nonblocking.
Here is a practical replacement that hides idle sleepers and sorts the longest-running active sessions first:
That gives you a custom process list without changing MySQL itself. You can keep adding filters for host, user, database, or statement type as needed.
Building a Reusable Custom View
If you run the same filtered query often, turn it into a view in an admin schema:
This pattern is much more maintainable than teaching everyone on the team a different long SELECT statement.
If you need lower-level details, query performance_schema.threads or related statement tables directly. That is where you can correlate a connection with waits, instrumentation, and other performance counters.
Privileges and Operational Notes
To see all sessions, you typically need the PROCESS privilege. Without it, MySQL limits what you can see to your own threads.
Also remember that process lists are snapshots, not long-term history. If you are troubleshooting intermittent spikes, combine process list queries with slow query logs, Performance Schema history tables, or external monitoring. SHOW PROCESSLIST and its replacements tell you what is happening now, not what happened five minutes ago.
Common Pitfalls
- Trying to change the output columns of
SHOW PROCESSLISTdirectly. The command format is fixed. - Building automation on top of
INFORMATION_SCHEMA.PROCESSLISTalone even though that implementation is deprecated in current MySQL documentation. - Forgetting the
PROCESSprivilege and then wondering why only your own sessions appear. - Looking only at
Sleeptime and ignoring statement latency, rows examined, or lock waits. - Using a one-off query every time instead of creating a reusable admin view for recurring investigations.
Summary
- You do not really customize
SHOW PROCESSLIST; you replace it with custom queries against better process information sources. - In modern MySQL,
sys.processlistand Performance Schema are the preferred foundations. - Filtering out sleepers and sorting by time or lock latency makes active issues much easier to spot.
- Create a view if your team needs the same custom process list repeatedly.
- Use process lists for live inspection, and combine them with longer-term monitoring for historical analysis.
Related reading
- How to customize the configuration file of the official PostgreSQL Docker image?
- How to deal with an apostrophe while writing into a MySQL database
- How to deal with persistent storage (e.g. databases) in Docker
- How to deal with persistent storage e.g. databases in Docker
- How to debug Lock wait timeout exceeded on MySQL?
- How to declare a variable in MySQL?
- How to define a custom ORDER BY order in mySQL
- How to define a key to GET human readable ids in REDIS?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.