|
| 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; |
0 commit comments