Description:
In my development environment I am using the default configuration of MySQL. I am trying to rewrite my fingers to use select * from sys.processlist instead of SHOW PROCESSLIST.
It is hard, because there are 21 background threads that are all idle which always show up. It would be nice to have a simple option to show only user threads.
How to repeat:
mysql [localhost] {msandbox} (sys) > select * from processlist\G
*************************** 1. row ***************************
thd_id: 1
conn_id: NULL
user: sql/main
db: NULL
command: NULL
state: NULL
time: 2076
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 2. row ***************************
thd_id: 24
conn_id: 1
user: sql/compress_gtid_table
db: NULL
command: Daemon
state: Suspending
time: 2076
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 3. row ***************************
thd_id: 28
conn_id: 5
user: msandbox@localhost
db: imdb
command: Sleep
state: NULL
time: 868
current_statement: NULL
lock_latency: 0 ps
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: 6.40 m
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 4. row ***************************
thd_id: 25
conn_id: 2
user: msandbox@localhost
db: imdb
command: Sleep
state: NULL
time: 789
current_statement: NULL
lock_latency: 0 ps
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: 5.08 m
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 5. row ***************************
thd_id: 32
conn_id: 9
user: msandbox@localhost
db: imdb
command: Sleep
state: NULL
time: 702
current_statement: NULL
lock_latency: 0 ps
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
current_memory: 0 bytes
last_statement: unlock tables
last_statement_latency: 132.15 us
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 6. row ***************************
thd_id: 29
conn_id: 6
user: msandbox@localhost
db: sys
command: Query
state: Sending data
time: 0
current_statement: select * from processlist
lock_latency: 642.00 us
rows_examined: 7826
rows_sent: 0
rows_affected: 0
tmp_tables: 4
tmp_disk_tables: 2
full_scan: YES
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 7. row ***************************
thd_id: 2
conn_id: NULL
user: sql/thread_timer_notifier
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 8. row ***************************
thd_id: 3
conn_id: NULL
user: innodb/io_ibuf_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 9. row ***************************
thd_id: 4
conn_id: NULL
user: innodb/io_log_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 10. row ***************************
thd_id: 5
conn_id: NULL
user: innodb/io_read_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 11. row ***************************
thd_id: 6
conn_id: NULL
user: innodb/io_read_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 12. row ***************************
thd_id: 7
conn_id: NULL
user: innodb/io_read_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 13. row ***************************
thd_id: 8
conn_id: NULL
user: innodb/io_read_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 14. row ***************************
thd_id: 9
conn_id: NULL
user: innodb/io_write_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 15. row ***************************
thd_id: 10
conn_id: NULL
user: innodb/io_write_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 16. row ***************************
thd_id: 11
conn_id: NULL
user: innodb/io_write_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 17. row ***************************
thd_id: 12
conn_id: NULL
user: innodb/io_write_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 18. row ***************************
thd_id: 13
conn_id: NULL
user: innodb/page_cleaner_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 19. row ***************************
thd_id: 16
conn_id: NULL
user: innodb/srv_lock_timeout_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 20. row ***************************
thd_id: 17
conn_id: NULL
user: innodb/srv_error_monitor_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 21. row ***************************
thd_id: 18
conn_id: NULL
user: innodb/srv_monitor_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 22. row ***************************
thd_id: 19
conn_id: NULL
user: innodb/srv_master_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 23. row ***************************
thd_id: 20
conn_id: NULL
user: innodb/srv_purge_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 24. row ***************************
thd_id: 21
conn_id: NULL
user: innodb/buf_dump_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 25. row ***************************
thd_id: 22
conn_id: NULL
user: innodb/dict_stats_thread
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
*************************** 26. row ***************************
thd_id: 23
conn_id: NULL
user: sql/signal_handler
db: NULL
command: NULL
state: NULL
time: NULL
current_statement: NULL
lock_latency: NULL
rows_examined: NULL
rows_sent: NULL
rows_affected: NULL
tmp_tables: NULL
tmp_disk_tables: NULL
full_scan: NO
current_memory: 0 bytes
last_statement: NULL
last_statement_latency: NULL
last_wait: NULL
last_wait_latency: NULL
source: NULL
26 rows in set (0.07 sec)
Suggested fix:
I know that I can type select * from sys.processlist where conn_id IS NOT NULL\G, but it's a few more key strokes than I would like. Is it possible to have:
SELECT * FROM sys.user_processlist;
There will be times when I will want the full processlist, and times I want the user session processlist.