1717 * View: user_summary
1818 *
1919 * Summarizes statement activity and connections by user
20+ *
21+ * When the user found is NULL, it is assumed to be a "background" thread.
2022 *
2123 * mysql> select * from user_summary;
2224 * +------+------------+---------------+-------------+---------------------+-------------------+--------------+----------------+------------------------+
@@ -46,7 +48,7 @@ VIEW user_summary (
4648 current_memory,
4749 total_memory_allocated
4850) AS
49- SELECT accounts .user ,
51+ SELECT IF( accounts .user IS NULL , ' background ' , accounts . user ) AS user,
5052 SUM (stmt .total ) AS statements,
5153 sys .format_time (SUM (stmt .total_latency )) AS statement_latency,
5254 sys .format_time (IFNULL(SUM (stmt .total_latency ) / NULLIF(SUM (stmt .total ), 0 ), 0 )) AS statement_avg_latency,
@@ -59,16 +61,17 @@ SELECT accounts.user,
5961 sys .format_bytes (mem .current_allocated ) AS current_memory,
6062 sys .format_bytes (mem .total_allocated ) AS total_memory_allocated
6163 FROM performance_schema .accounts
62- JOIN sys .x $user_summary_by_statement_latency AS stmt ON accounts .user = stmt .user
63- JOIN sys .x $user_summary_by_file_io AS io ON accounts .user = io .user
64- JOIN sys .x $memory_by_user_by_current_bytes mem ON accounts .user = mem .user
65- WHERE accounts .user IS NOT NULL
66- GROUP BY accounts .user ;
64+ LEFT JOIN sys .x $user_summary_by_statement_latency AS stmt ON IF(accounts .user IS NULL , ' background' , accounts .user ) = stmt .user
65+ LEFT JOIN sys .x $user_summary_by_file_io AS io ON IF(accounts .user IS NULL , ' background' , accounts .user ) = io .user
66+ LEFT JOIN sys .x $memory_by_user_by_current_bytes mem ON IF(accounts .user IS NULL , ' background' , accounts .user ) = mem .user
67+ GROUP BY IF(accounts .user IS NULL , ' background' , accounts .user );
6768
6869/*
6970 * View: x$user_summary
7071 *
7172 * Summarizes statement activity and connections by user
73+ *
74+ * When the user found is NULL, it is assumed to be a "background" thread.
7275 *
7376 * mysql> select * from x$user_summary;
7477 * +------+------------+-----------------+------------------+---------------------+-------------------+--------------+----------------+------------------------+
@@ -98,7 +101,7 @@ VIEW x$user_summary (
98101 current_memory,
99102 total_memory_allocated
100103) AS
101- SELECT accounts .user ,
104+ SELECT IF( accounts .user IS NULL , ' background ' , accounts . user ) AS user,
102105 SUM (stmt .total ) AS statements,
103106 SUM (stmt .total_latency ) AS statement_latency,
104107 IFNULL(SUM (stmt .total_latency ) / NULLIF(SUM (stmt .total ), 0 ), 0 ) AS statement_avg_latency,
@@ -111,8 +114,7 @@ SELECT accounts.user,
111114 mem .current_allocated AS current_memory,
112115 mem .total_allocated AS total_memory_allocated
113116 FROM performance_schema .accounts
114- JOIN sys .x $user_summary_by_statement_latency AS stmt ON accounts .user = stmt .user
115- JOIN sys .x $user_summary_by_file_io AS io ON accounts .user = io .user
116- JOIN sys .x $memory_by_user_by_current_bytes mem ON accounts .user = mem .user
117- WHERE accounts .user IS NOT NULL
118- GROUP BY accounts .user ;
117+ LEFT JOIN sys .x $user_summary_by_statement_latency AS stmt ON IF(accounts .user IS NULL , ' background' , accounts .user ) = stmt .user
118+ LEFT JOIN sys .x $user_summary_by_file_io AS io ON IF(accounts .user IS NULL , ' background' , accounts .user ) = io .user
119+ LEFT JOIN sys .x $memory_by_user_by_current_bytes mem ON IF(accounts .user IS NULL , ' background' , accounts .user ) = mem .user
120+ GROUP BY IF(accounts .user IS NULL , ' background' , accounts .user );
0 commit comments