Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit b7b7ce8

Browse files
committed
Update the host summary views to support the new 5.7 ONLY_FULL_GROUP_BY mode with functional dependencies, as well as to show background thread usage like the user summary views
1 parent bcb0e93 commit b7b7ce8

7 files changed

+163
-146
lines changed

views/p_s/host_summary.sql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
* Summarizes statement activity, file IO and connections by host.
2020
*
21+
* When the host found is NULL, it is assumed to be a "background" thread.
22+
*
2123
* mysql> select * from host_summary;
2224
* +------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+
2325
* | host | statements | statement_latency | statement_avg_latency | table_scans | file_ios | file_io_latency | current_connections | total_connections | unique_users |
@@ -43,7 +45,7 @@ VIEW host_summary (
4345
total_connections,
4446
unique_hosts
4547
) AS
46-
SELECT accounts.host,
48+
SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host,
4749
SUM(stmt.total) AS statements,
4850
sys.format_time(SUM(stmt.total_latency)) AS statement_latency,
4951
sys.format_time(SUM(stmt.total_latency) / SUM(stmt.total)) AS statement_avg_latency,
@@ -56,14 +58,15 @@ SELECT accounts.host,
5658
FROM performance_schema.accounts
5759
LEFT JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host
5860
LEFT JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host
59-
WHERE accounts.host IS NOT NULL
60-
GROUP BY accounts.host;
61+
GROUP BY IF(accounts.host IS NULL, 'background', accounts.host);
6162

6263
/*
6364
* View: x$host_summary
6465
*
6566
* Summarizes statement activity, file IO and connections by host.
6667
*
68+
* When the host found is NULL, it is assumed to be a "background" thread.
69+
*
6770
* mysql> select * from x$host_summary;
6871
* +------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+
6972
* | host | statements | statement_latency | statement_avg_latency | table_scans | file_ios | file_io_latency | current_connections | total_connections | unique_users|
@@ -89,7 +92,7 @@ VIEW x$host_summary (
8992
total_connections,
9093
unique_hosts
9194
) AS
92-
SELECT accounts.host,
95+
SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host,
9396
SUM(stmt.total) AS statements,
9497
SUM(stmt.total_latency) AS statement_latency,
9598
SUM(stmt.total_latency) / SUM(stmt.total) AS statement_avg_latency,
@@ -102,5 +105,4 @@ SELECT accounts.host,
102105
FROM performance_schema.accounts
103106
LEFT JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host
104107
LEFT JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host
105-
WHERE accounts.host IS NOT NULL
106-
GROUP BY accounts.host;
108+
GROUP BY IF(accounts.host IS NULL, 'background', accounts.host);

views/p_s/host_summary_57.sql

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
* Summarizes statement activity and connections by host
2020
*
21+
* When the host found is NULL, it is assumed to be a "background" thread.
22+
*
2123
* mysql> select * from host_summary;
2224
* +------+------------+---------------+-------------+---------------------+-------------------+--------------+----------------+------------------------+
2325
* | host | statements | total_latency | avg_latency | current_connections | total_connections | unique_users | current_memory | total_memory_allocated |
@@ -46,7 +48,7 @@ VIEW host_summary (
4648
current_memory,
4749
total_memory_allocated
4850
) AS
49-
SELECT accounts.host,
51+
SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host,
5052
SUM(stmt.total) AS statements,
5153
sys.format_time(SUM(stmt.total_latency)) AS statement_latency,
5254
sys.format_time(SUM(stmt.total_latency) / SUM(stmt.total)) AS statement_avg_latency,
@@ -56,20 +58,21 @@ SELECT accounts.host,
5658
SUM(accounts.current_connections) AS current_connections,
5759
SUM(accounts.total_connections) AS total_connections,
5860
COUNT(DISTINCT user) AS unique_users,
59-
sys.format_bytes(mem.current_allocated) AS current_memory,
60-
sys.format_bytes(mem.total_allocated) AS total_memory_allocated
61+
sys.format_bytes(SUM(mem.current_allocated)) AS current_memory,
62+
sys.format_bytes(SUM(mem.total_allocated)) AS total_memory_allocated
6163
FROM performance_schema.accounts
6264
JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host
6365
JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host
6466
JOIN sys.x$memory_by_host_by_current_bytes mem ON accounts.host = mem.host
65-
WHERE accounts.host IS NOT NULL
66-
GROUP BY accounts.host;
67+
GROUP BY IF(accounts.host IS NULL, 'background', accounts.host);
6768

6869
/*
6970
* View: x$host_summary
7071
*
7172
* Summarizes statement activity and connections by host
7273
*
74+
* When the host found is NULL, it is assumed to be a "background" thread.
75+
*
7376
* mysql> select * from x$host_summary;
7477
* +------+------------+-----------------+------------------+---------------------+-------------------+--------------+----------------+------------------------+
7578
* | host | statements | total_latency | avg_latency | current_connections | total_connections | unique_users | current_memory | total_memory_allocated |
@@ -98,7 +101,7 @@ VIEW x$host_summary (
98101
current_memory,
99102
total_memory_allocated
100103
) AS
101-
SELECT accounts.host,
104+
SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host,
102105
SUM(stmt.total) AS statements,
103106
SUM(stmt.total_latency) AS statement_latency,
104107
SUM(stmt.total_latency) / SUM(stmt.total) AS statement_avg_latency,
@@ -108,11 +111,10 @@ SELECT accounts.host,
108111
SUM(accounts.current_connections) AS current_connections,
109112
SUM(accounts.total_connections) AS total_connections,
110113
COUNT(DISTINCT accounts.user) AS unique_users,
111-
mem.current_allocated AS current_memory,
112-
mem.total_allocated AS total_memory_allocated
114+
SUM(mem.current_allocated) AS current_memory,
115+
SUM(mem.total_allocated) AS total_memory_allocated
113116
FROM performance_schema.accounts
114117
JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host
115118
JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host
116119
JOIN sys.x$memory_by_host_by_current_bytes mem ON accounts.host = mem.host
117-
WHERE accounts.host IS NOT NULL
118-
GROUP BY accounts.host;
120+
GROUP BY IF(accounts.host IS NULL, 'background', accounts.host);

views/p_s/host_summary_by_file_io.sql

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
* Summarizes file IO totals per host.
2020
*
21+
* When the host found is NULL, it is assumed to be a "background" thread.
22+
*
2123
* mysql> select * from host_summary_by_file_io;
2224
* +------------+-------+------------+
2325
* | host | ios | io_latency |
@@ -37,18 +39,19 @@ VIEW host_summary_by_file_io (
3739
ios,
3840
io_latency
3941
) AS
40-
SELECT host,
41-
SUM(total) AS ios,
42-
sys.format_time(SUM(latency)) AS io_latency
43-
FROM x$host_summary_by_file_io_type
44-
GROUP BY host
45-
ORDER BY SUM(latency) DESC;
42+
SELECT IF(host IS NULL, 'background', host) AS host,
43+
SUM(count_star) AS ios,
44+
sys.format_time(SUM(sum_timer_wait)) AS io_latency
45+
FROM performance_schema.events_waits_summary_by_host_by_event_name
46+
GROUP BY IF(host IS NULL, 'background', host)
47+
ORDER BY SUM(sum_timer_wait) DESC;
4648

4749
/*
4850
* View: x$host_summary_by_file_io
4951
*
5052
* Summarizes file IO totals per host.
5153
*
54+
* When the host found is NULL, it is assumed to be a "background" thread.
5255
*
5356
* mysql> select * from x$host_summary_by_file_io;
5457
* +------------+-------+----------------+
@@ -69,9 +72,9 @@ VIEW x$host_summary_by_file_io (
6972
ios,
7073
io_latency
7174
) AS
72-
SELECT host,
73-
SUM(total) AS ios,
74-
SUM(latency) AS io_latency
75-
FROM x$host_summary_by_file_io_type
76-
GROUP BY host
77-
ORDER BY SUM(latency) DESC;
75+
SELECT IF(host IS NULL, 'background', host) AS host,
76+
SUM(count_star) AS ios,
77+
SUM(sum_timer_wait) AS io_latency
78+
FROM performance_schema.events_waits_summary_by_host_by_event_name
79+
GROUP BY IF(host IS NULL, 'background', host)
80+
ORDER BY SUM(sum_timer_wait) DESC;

views/p_s/host_summary_by_file_io_type.sql

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,30 @@
1818
*
1919
* Summarizes file IO by event type per host.
2020
*
21+
* When the host found is NULL, it is assumed to be a "background" thread.
2122
*
2223
* mysql> select * from host_summary_by_file_io_type;
23-
* +------------+--------------------------------------+-------+-----------+-------------+
24-
* | host | event_name | total | latency | max_latency |
25-
* +------------+--------------------------------------+-------+-----------+-------------+
26-
* | hal1 | wait/io/file/sql/FRM | 871 | 168.15 ms | 18.48 ms |
27-
* | hal1 | wait/io/file/innodb/innodb_data_file | 173 | 129.56 ms | 34.09 ms |
28-
* | hal1 | wait/io/file/innodb/innodb_log_file | 20 | 77.53 ms | 60.66 ms |
29-
* | hal1 | wait/io/file/myisam/dfile | 40 | 6.54 ms | 4.58 ms |
30-
* | hal1 | wait/io/file/mysys/charset | 3 | 4.79 ms | 4.71 ms |
31-
* | hal1 | wait/io/file/myisam/kfile | 67 | 4.38 ms | 300.04 us |
32-
* | hal1 | wait/io/file/sql/ERRMSG | 5 | 2.72 ms | 1.69 ms |
33-
* | hal1 | wait/io/file/sql/pid | 3 | 266.30 us | 185.47 us |
34-
* | hal1 | wait/io/file/sql/casetest | 5 | 246.81 us | 150.19 us |
35-
* | hal1 | wait/io/file/sql/global_ddl_log | 2 | 21.24 us | 18.59 us |
36-
* | hal2 | wait/io/file/sql/file_parser | 1422 | 4.80 s | 135.14 ms |
37-
* | hal2 | wait/io/file/sql/FRM | 865 | 85.82 ms | 9.81 ms |
38-
* | hal2 | wait/io/file/myisam/kfile | 1073 | 37.14 ms | 15.79 ms |
39-
* | hal2 | wait/io/file/myisam/dfile | 2991 | 25.53 ms | 5.25 ms |
40-
* | hal2 | wait/io/file/sql/dbopt | 20 | 1.07 ms | 153.07 us |
41-
* | hal2 | wait/io/file/sql/misc | 4 | 59.71 us | 33.75 us |
42-
* | hal2 | wait/io/file/archive/data | 1 | 13.91 us | 13.91 us |
43-
* +------------+--------------------------------------+-------+-----------+-------------+
24+
* +------------+--------------------------------------+-------+---------------+-------------+
25+
* | host | event_name | total | total_latency | max_latency |
26+
* +------------+--------------------------------------+-------+---------------+-------------+
27+
* | hal1 | wait/io/file/sql/FRM | 871 | 168.15 ms | 18.48 ms |
28+
* | hal1 | wait/io/file/innodb/innodb_data_file | 173 | 129.56 ms | 34.09 ms |
29+
* | hal1 | wait/io/file/innodb/innodb_log_file | 20 | 77.53 ms | 60.66 ms |
30+
* | hal1 | wait/io/file/myisam/dfile | 40 | 6.54 ms | 4.58 ms |
31+
* | hal1 | wait/io/file/mysys/charset | 3 | 4.79 ms | 4.71 ms |
32+
* | hal1 | wait/io/file/myisam/kfile | 67 | 4.38 ms | 300.04 us |
33+
* | hal1 | wait/io/file/sql/ERRMSG | 5 | 2.72 ms | 1.69 ms |
34+
* | hal1 | wait/io/file/sql/pid | 3 | 266.30 us | 185.47 us |
35+
* | hal1 | wait/io/file/sql/casetest | 5 | 246.81 us | 150.19 us |
36+
* | hal1 | wait/io/file/sql/global_ddl_log | 2 | 21.24 us | 18.59 us |
37+
* | hal2 | wait/io/file/sql/file_parser | 1422 | 4.80 s | 135.14 ms |
38+
* | hal2 | wait/io/file/sql/FRM | 865 | 85.82 ms | 9.81 ms |
39+
* | hal2 | wait/io/file/myisam/kfile | 1073 | 37.14 ms | 15.79 ms |
40+
* | hal2 | wait/io/file/myisam/dfile | 2991 | 25.53 ms | 5.25 ms |
41+
* | hal2 | wait/io/file/sql/dbopt | 20 | 1.07 ms | 153.07 us |
42+
* | hal2 | wait/io/file/sql/misc | 4 | 59.71 us | 33.75 us |
43+
* | hal2 | wait/io/file/archive/data | 1 | 13.91 us | 13.91 us |
44+
* +------------+--------------------------------------+-------+---------------+-------------+
4445
*
4546
*/
4647

@@ -52,28 +53,29 @@ VIEW host_summary_by_file_io_type (
5253
host,
5354
event_name,
5455
total,
55-
latency,
56+
total_latency,
5657
max_latency
5758
) AS
58-
SELECT host AS host,
59+
SELECT IF(host IS NULL, 'background', host) AS host,
5960
event_name,
6061
count_star AS total,
61-
sys.format_time(sum_timer_wait) AS latency,
62+
sys.format_time(sum_timer_wait) AS total_latency,
6263
sys.format_time(max_timer_wait) AS max_latency
6364
FROM performance_schema.events_waits_summary_by_host_by_event_name
6465
WHERE event_name LIKE 'wait/io/file%'
6566
AND count_star > 0
66-
ORDER BY host, sum_timer_wait DESC;
67+
ORDER BY IF(host IS NULL, 'background', host), sum_timer_wait DESC;
6768

6869
/*
6970
* View: x$host_summary_by_file_io_type
7071
*
7172
* Summarizes file IO by event type per host.
7273
*
74+
* When the host found is NULL, it is assumed to be a "background" thread.
7375
*
7476
* mysql> select * from x$host_summary_by_file_io_type;
7577
* +------------+--------------------------------------+-------+---------------+--------------+
76-
* | host | event_name | total | latency | max_latency |
78+
* | host | event_name | total | total_latency | max_latency |
7779
* +------------+--------------------------------------+-------+---------------+--------------+
7880
* | hal1 | wait/io/file/sql/FRM | 871 | 168148450470 | 18482624810 |
7981
* | hal1 | wait/io/file/innodb/innodb_data_file | 173 | 129564287450 | 34087423890 |
@@ -104,15 +106,15 @@ VIEW x$host_summary_by_file_io_type (
104106
host,
105107
event_name,
106108
total,
107-
latency,
109+
total_latency,
108110
max_latency
109111
) AS
110-
SELECT host AS host,
112+
SELECT IF(host IS NULL, 'background', host) AS host,
111113
event_name,
112114
count_star AS total,
113-
sum_timer_wait AS latency,
115+
sum_timer_wait AS total_latency,
114116
max_timer_wait AS max_latency
115117
FROM performance_schema.events_waits_summary_by_host_by_event_name
116118
WHERE event_name LIKE 'wait/io/file%'
117119
AND count_star > 0
118-
ORDER BY host, sum_timer_wait DESC;
120+
ORDER BY IF(host IS NULL, 'background', host), sum_timer_wait DESC;

0 commit comments

Comments
 (0)