Decoding MySQL Processlist: Understand Columns, States, and Performance Issues
This guide explains how to use MySQL's show processlist command, interprets each column and common state values, and offers practical tips for diagnosing and resolving performance problems such as sleeping connections, locked queries, temporary tables, and query cache issues.
Viewing MySQL Execution Status
When MySQL performance seems degraded, start by checking the current execution status with show processlist:
+----+------+-------------------+-------+---------+------+--------+-------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-------------------+-------+---------+------+--------+-------+
|207|root|192.168.0.2:51621|mytest|Sleep|5||NULL|
|208|root|192.168.0.2:51622|mytest|Sleep|5||NULL|
|220|root|192.168.0.2:51676|mytest|Query|84|locked|
+----+------+-------------------+-------+---------+------+--------+-------+Column meanings
Id : Identifier of the thread; use it with kill <id> to terminate a query.
User : The account that issued the statement; non‑root users see only their own queries.
Host : IP address and port of the client, useful for tracing problematic users.
Db : Database currently selected by the thread.
Command : Type of command, e.g., Sleep, Query, Connect.
Time : Duration (in seconds) the command has been in its current state.
State : Detailed status of the executing SQL, such as Copy to tmp table, Sorting result, Sending data, etc.
Info : The actual SQL statement (truncated if long); essential for diagnosing issues.
Common State Analysis
Sleep : Indicates an idle connection; excessive sleep may mean connections are not being closed properly.
Locked : The operation is waiting for a lock; using InnoDB can reduce this occurrence.
Copy to tmp table : MySQL creates a temporary table when indexes cannot satisfy the query, causing high I/O; consider reducing joins or optimizing the query, and kill long‑running statements if needed.
Sending data : Refers to reading data from disk rather than network transmission; many such connections often mean large result sets or missing indexes.
Storing result to query cache : Frequent appearance suggests query cache fragmentation; use set profiling to analyze and flush query cache to clear, adjusting cache parameters as appropriate.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
