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

Commit a83e2ae

Browse files
committed
Add missing waits_by_host_by_latency.sql file. Update the waits_by_user_by_latency view to also include background thread info as with other user summary views. Perhaps this should be a user_summary_by_waits_by_latency, and similar for the host one, for consistency, but not done here.
1 parent 9ffcfad commit a83e2ae

File tree

3 files changed

+103
-7
lines changed

3 files changed

+103
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ mysql> select * from wait_classes_global_by_latency;
11051105
11061106
##### Description
11071107
1108-
Lists the top wait events by their total latency, ignoring idle (this may be very large) per user.
1108+
Lists the top wait events per user by their total latency, ignoring idle (this may be very large) per user.
11091109
11101110
##### Example
11111111
@@ -1136,7 +1136,7 @@ mysql> select * from waits_by_user_by_latency;
11361136
11371137
##### Description
11381138
1139-
Lists the top wait events by their total latency, ignoring idle (this may be very large) per host.
1139+
Lists the top wait events per host by their total latency, ignoring idle (this may be very large) per host.
11401140
11411141
##### Example
11421142
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
/*
17+
* View: waits_by_host_by_latency
18+
*
19+
* Lists the top wait events per host by their total latency, ignoring idle (this may be very large).
20+
*
21+
* mysql> select * from sys.waits_by_host_by_latency where host != 'background' limit 5;
22+
* +-----------+------------------------------+-------+---------------+-------------+-------------+
23+
* | host | event | total | total_latency | avg_latency | max_latency |
24+
* +-----------+------------------------------+-------+---------------+-------------+-------------+
25+
* | localhost | wait/io/file/sql/file_parser | 1386 | 14.50 s | 10.46 ms | 357.36 ms |
26+
* | localhost | wait/io/file/sql/FRM | 162 | 356.08 ms | 2.20 ms | 75.33 ms |
27+
* | localhost | wait/io/file/myisam/kfile | 410 | 322.29 ms | 786.08 us | 65.98 ms |
28+
* | localhost | wait/io/file/myisam/dfile | 1327 | 307.44 ms | 231.68 us | 37.16 ms |
29+
* | localhost | wait/io/file/sql/dbopt | 89 | 180.34 ms | 2.03 ms | 63.41 ms |
30+
* +-----------+------------------------------+-------+---------------+-------------+-------------+
31+
*
32+
*/
33+
34+
CREATE OR REPLACE
35+
ALGORITHM = MERGE
36+
DEFINER = 'root'@'localhost'
37+
SQL SECURITY INVOKER
38+
VIEW waits_by_host_by_latency (
39+
host,
40+
event,
41+
total,
42+
total_latency,
43+
avg_latency,
44+
max_latency
45+
) AS
46+
SELECT IF(host IS NULL, 'background', host) AS host,
47+
event_name AS event,
48+
count_star AS total,
49+
sys.format_time(sum_timer_wait) AS total_latency,
50+
sys.format_time(avg_timer_wait) AS avg_latency,
51+
sys.format_time(max_timer_wait) AS max_latency
52+
FROM performance_schema.events_waits_summary_by_host_by_event_name
53+
WHERE event_name != 'idle'
54+
AND sum_timer_wait > 0
55+
ORDER BY host, sum_timer_wait DESC;
56+
57+
/*
58+
* View: waits_by_host_by_latency
59+
*
60+
* Lists the top wait events per host by their total latency, ignoring idle (this may be very large).
61+
*
62+
* mysql> select * from sys.x$waits_by_host_by_latency where host != 'background' limit 5;
63+
* +-----------+------------------------------+-------+----------------+-------------+--------------+
64+
* | host | event | total | total_latency | avg_latency | max_latency |
65+
* +-----------+------------------------------+-------+----------------+-------------+--------------+
66+
* | localhost | wait/io/file/sql/file_parser | 1388 | 14502657551590 | 10448600240 | 357364034170 |
67+
* | localhost | wait/io/file/sql/FRM | 167 | 361060236420 | 2162037319 | 75331088170 |
68+
* | localhost | wait/io/file/myisam/kfile | 410 | 322294755250 | 786084585 | 65978227120 |
69+
* | localhost | wait/io/file/myisam/dfile | 1327 | 307435262550 | 231676679 | 37162925800 |
70+
* | localhost | wait/io/file/sql/dbopt | 89 | 180341976360 | 2026314303 | 63405386850 |
71+
* +-----------+------------------------------+-------+----------------+-------------+--------------+
72+
*
73+
*/
74+
75+
CREATE OR REPLACE
76+
ALGORITHM = MERGE
77+
DEFINER = 'root'@'localhost'
78+
SQL SECURITY INVOKER
79+
VIEW x$waits_by_host_by_latency (
80+
host,
81+
event,
82+
total,
83+
total_latency,
84+
avg_latency,
85+
max_latency
86+
) AS
87+
SELECT IF(host IS NULL, 'background', host) AS host,
88+
event_name AS event,
89+
count_star AS total,
90+
sum_timer_wait AS total_latency,
91+
avg_timer_wait AS avg_latency,
92+
max_timer_wait AS max_latency
93+
FROM performance_schema.events_waits_summary_by_host_by_event_name
94+
WHERE event_name != 'idle'
95+
AND sum_timer_wait > 0
96+
ORDER BY host, sum_timer_wait DESC;

views/p_s/waits_by_user_by_latency.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/*
1717
* View: waits_by_user_by_latency
1818
*
19-
* Lists the top wait events by their total latency, ignoring idle (this may be very large).
19+
* Lists the top wait events per user by their total latency, ignoring idle (this may be very large).
2020
*
2121
* mysql> select * from waits_by_user_by_latency;
2222
* +------+-----------------------------------------------------+--------+---------------+-------------+-------------+
@@ -53,7 +53,7 @@ VIEW waits_by_user_by_latency (
5353
avg_latency,
5454
max_latency
5555
) AS
56-
SELECT user,
56+
SELECT IF(user IS NULL, 'background', user) AS user,
5757
event_name AS event,
5858
count_star AS total,
5959
sys.format_time(sum_timer_wait) AS total_latency,
@@ -66,9 +66,9 @@ SELECT user,
6666
ORDER BY user, sum_timer_wait DESC;
6767

6868
/*
69-
* View: waits_by_user_by_latency_raw
69+
* View: waits_by_user_by_latency
7070
*
71-
* Lists the top wait events by their total latency, ignoring idle (this may be very large).
71+
* Lists the top wait events per user by their total latency, ignoring idle (this may be very large).
7272
*
7373
* mysql> select * from x$waits_by_user_by_latency;
7474
* +------+-----------------------------------------------------+--------+----------------+-------------+--------------+
@@ -105,7 +105,7 @@ VIEW x$waits_by_user_by_latency (
105105
avg_latency,
106106
max_latency
107107
) AS
108-
SELECT user,
108+
SELECT IF(user IS NULL, 'background', user) AS user,
109109
event_name AS event,
110110
count_star AS total,
111111
sum_timer_wait AS total_latency,

0 commit comments

Comments
 (0)