SELECT IF ( `isnull` ( `performance_schema` . `threads` . `PROCESSLIST_ID` ) , `substring_index` ( `performance_schema` . `threads` . `NAME` , ? , - (?) ) , `concat` ( `performance_schema` . `threads` . `PROCESSLIST_USER` , ? , `performance_schema` . `threads` . `PROCESSLIST_HOST` ) ) AS `user` , SUM ( `performance_schema` . `events_waits_summary_by_thread_by_event_name` . `COUNT_STAR` ) AS `total` , `sys` . `format_time` ( SUM ( `performance_schema` . `events_waits_summary_by_thread_by_event_name` . `SUM_TIMER_WAIT` ) ) AS `total_latency` , `sys` . `format_time` ( MIN ( `performance_schema` . `events_waits_summary_by_thread_by_event_name` . `MIN_TIMER_WAIT` ) ) AS `min_latency` , `sys` . `format_time` ( AVG ( `performance_schema` . `events_waits_summary_by_thread_by_event_name` . `AVG_TIMER_WAIT` ) ) AS `avg_latency` , `sys` . `format_time` ( MAX ( `performance_schema` . `events_waits_summary_by_thread_by_event_name` . `MAX_TIMER_WAIT` ) ) AS `max_latency` , `performance_schema` . 