77 * mysql> select * from processlist_full where conn_id is not null\G
88 * ...
99 * *************************** 8. row ***************************
10- * thd_id: 12400
11- * conn_id: 12379
10+ * thd_id: 31
11+ * conn_id: 12
1212 * user: root@localhost
1313 * db: ps_helper
1414 * command: Query
15- * state: Copying to tmp table
15+ * state: Sending data
1616 * time: 0
17- * current_statement: select * from processlist_full where conn_id is not null
18- * last_statement: NULL
19- * last_statement_latency: NULL
20- * lock_latency: 1.00 ms
17+ * current_statement: select * from processlist limit 5
18+ * lock_latency: 684.00 us
2119 * rows_examined: 0
2220 * rows_sent: 0
2321 * rows_affected: 0
24- * tmp_tables: 1
22+ * tmp_tables: 2
2523 * tmp_disk_tables: 0
2624 * full_scan: YES
27- * last_wait: wait/synch/mutex/sql/THD::LOCK_thd_data
28- * last_wait_latency: 62.53 ns
29- * source: sql_class.h:3843
25+ * current_memory: 1.29 MiB
26+ * last_statement: NULL
27+ * last_statement_latency: NULL
28+ * last_wait: wait/synch/mutex/sql/THD::LOCK_query_plan
29+ * last_wait_latency: 260.13 ns
30+ * source: sql_optimizer.cc:1075
3031 *
31- * Versions: 5.6 .2+
32+ * Versions: 5.7 .2+
3233 *
3334 */
3435
@@ -80,29 +81,29 @@ ORDER BY pps.processlist_time DESC, last_wait_latency DESC;
8081 *
8182 * mysql> select * from processlist_full where conn_id is not null\G
8283 * *************************** 1. row ***************************
83- * thd_id: 25
84- * conn_id: 6
84+ * thd_id: 31
85+ * conn_id: 12
8586 * user: root@localhost
8687 * db: ps_helper
8788 * command: Query
8889 * state: Sending data
8990 * time: 0
90- * current_statement: select * from processlist_full where conn_id is not null
91- * last_statement: NULL
92- * last_statement_latency: NULL
93- * lock_latency: 741.00 us
91+ * current_statement: select * from processlist_raw limit 5
92+ * lock_latency: 1066000000
9493 * rows_examined: 0
9594 * rows_sent: 0
9695 * rows_affected: 0
97- * tmp_tables: 1
98- * tmp_disk_tables: 0
96+ * tmp_tables: 2
97+ * tmp_disk_tables: 1
9998 * full_scan: YES
100- * last_wait: wait/synch/mutex/sql/THD::LOCK_query_plan
101- * last_wait_latency: 196.04 ns
102- * source: sql_optimizer.cc:1075
103- * 1 row in set (0.00 sec)
99+ * current_memory: 1464694
100+ * last_statement: NULL
101+ * last_statement_latency: NULL
102+ * last_wait: wait/io/file/myisam/dfile
103+ * last_wait_latency: 1602250
104+ * source: mf_iocache.c:163
104105 *
105- * Versions: 5.6 .2+
106+ * Versions: 5.7 .2+
106107 *
107108 */
108109
@@ -119,20 +120,21 @@ SELECT pps.thread_id AS thd_id,
119120 pps .processlist_state AS state,
120121 pps .processlist_time AS time ,
121122 pps .processlist_info AS current_statement,
122- IF(esc .timer_wait IS NOT NULL ,
123- esc .sql_text ,
124- NULL ) AS last_statement,
125- IF(esc .timer_wait IS NOT NULL ,
126- esc .timer_wait ,
127- NULL ) as last_statement_latency,
128123 esc .lock_time AS lock_latency,
129124 esc .rows_examined ,
130125 esc .rows_sent ,
131126 esc .rows_affected ,
132127 esc .created_tmp_tables AS tmp_tables,
133- esc .created_tmp_disk_tables as tmp_disk_tables,
128+ esc .created_tmp_disk_tables AS tmp_disk_tables,
134129 IF(esc .no_good_index_used > 0 OR esc .no_index_used > 0 ,
135130 ' YES' , ' NO' ) AS full_scan,
131+ SUM (mem .current_number_of_bytes_used ) AS current_memory,
132+ IF(esc .timer_wait IS NOT NULL ,
133+ esc .sql_text ,
134+ NULL ) AS last_statement,
135+ IF(esc .timer_wait IS NOT NULL ,
136+ esc .timer_wait ,
137+ NULL ) as last_statement_latency,
136138 ewc .event_name AS last_wait,
137139 IF(ewc .timer_wait IS NULL AND ewc .event_name IS NOT NULL ,
138140 ' Still Waiting' ,
@@ -141,4 +143,6 @@ SELECT pps.thread_id AS thd_id,
141143 FROM performance_schema .threads AS pps
142144 LEFT JOIN performance_schema .events_waits_current AS ewc USING (thread_id)
143145 LEFT JOIN performance_schema .events_statements_current as esc USING (thread_id)
146+ LEFT JOIN performance_schema .memory_summary_by_thread_by_event_name as mem USING (thread_id)
147+ GROUP BY thread_id
144148ORDER BY pps .processlist_time DESC , last_wait_latency DESC ;
0 commit comments