|
| 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: host_summary_by_stages |
| 18 | + * |
| 19 | + * Summarizes stages by host, ordered by host and total latency per stage. |
| 20 | + * |
| 21 | + * mysql> select * from host_summary_by_stages; |
| 22 | + * +------+--------------------------------+-------+-----------+-----------+ |
| 23 | + * | host | event_name | total | wait_sum | wait_avg | |
| 24 | + * +------+--------------------------------+-------+-----------+-----------+ |
| 25 | + * | hal | stage/sql/Opening tables | 889 | 1.97 ms | 2.22 us | |
| 26 | + * | hal | stage/sql/Creating sort index | 4 | 1.79 ms | 446.30 us | |
| 27 | + * | hal | stage/sql/init | 10 | 312.27 us | 31.23 us | |
| 28 | + * | hal | stage/sql/checking permissions | 10 | 300.62 us | 30.06 us | |
| 29 | + * | hal | stage/sql/freeing items | 5 | 85.89 us | 17.18 us | |
| 30 | + * | hal | stage/sql/statistics | 5 | 79.15 us | 15.83 us | |
| 31 | + * | hal | stage/sql/preparing | 5 | 69.12 us | 13.82 us | |
| 32 | + * | hal | stage/sql/optimizing | 5 | 53.11 us | 10.62 us | |
| 33 | + * | hal | stage/sql/Sending data | 5 | 44.66 us | 8.93 us | |
| 34 | + * | hal | stage/sql/closing tables | 5 | 37.54 us | 7.51 us | |
| 35 | + * | hal | stage/sql/System lock | 5 | 34.28 us | 6.86 us | |
| 36 | + * | hal | stage/sql/query end | 5 | 24.37 us | 4.87 us | |
| 37 | + * | hal | stage/sql/end | 5 | 8.60 us | 1.72 us | |
| 38 | + * | hal | stage/sql/Sorting result | 5 | 8.33 us | 1.67 us | |
| 39 | + * | hal | stage/sql/executing | 5 | 5.37 us | 1.07 us | |
| 40 | + * | hal | stage/sql/cleaning up | 5 | 4.60 us | 919.00 ns | |
| 41 | + * +------+--------------------------------+-------+-----------+-----------+ |
| 42 | + * |
| 43 | + */ |
| 44 | + |
| 45 | +CREATE OR REPLACE |
| 46 | + ALGORITHM = MERGE |
| 47 | + DEFINER = 'root'@'localhost' |
| 48 | + SQL SECURITY INVOKER |
| 49 | +VIEW host_summary_by_stages ( |
| 50 | + host, |
| 51 | + event_name, |
| 52 | + total, |
| 53 | + wait_sum, |
| 54 | + wait_avg |
| 55 | +) AS |
| 56 | +SELECT host, |
| 57 | + event_name, |
| 58 | + count_star AS total, |
| 59 | + sys.format_time(sum_timer_wait) AS wait_sum, |
| 60 | + sys.format_time(avg_timer_wait) AS wait_avg |
| 61 | + FROM performance_schema.events_stages_summary_by_host_by_event_name |
| 62 | + WHERE host IS NOT NULL |
| 63 | + AND sum_timer_wait != 0 |
| 64 | + ORDER BY host, sum_timer_wait DESC; |
| 65 | + |
| 66 | +/* |
| 67 | + * View: x$host_summary_by_stages |
| 68 | + * |
| 69 | + * Summarizes stages by host, ordered by host and total latency per stage. |
| 70 | + * |
| 71 | + * mysql> select * from x$host_summary_by_stages; |
| 72 | + * +------+--------------------------------+-------+-------------+-----------+ |
| 73 | + * | host | event_name | total | wait_sum | wait_avg | |
| 74 | + * +------+--------------------------------+-------+-------------+-----------+ |
| 75 | + * | hal | stage/sql/Opening tables | 1114 | 71919037000 | 64559000 | |
| 76 | + * | hal | stage/sql/Creating sort index | 5 | 2245762000 | 449152000 | |
| 77 | + * | hal | stage/sql/init | 13 | 428798000 | 32984000 | |
| 78 | + * | hal | stage/sql/checking permissions | 13 | 363231000 | 27940000 | |
| 79 | + * | hal | stage/sql/freeing items | 7 | 137728000 | 19675000 | |
| 80 | + * | hal | stage/sql/statistics | 6 | 93955000 | 15659000 | |
| 81 | + * | hal | stage/sql/preparing | 6 | 82571000 | 13761000 | |
| 82 | + * | hal | stage/sql/optimizing | 6 | 63338000 | 10556000 | |
| 83 | + * | hal | stage/sql/Sending data | 6 | 53400000 | 8900000 | |
| 84 | + * | hal | stage/sql/closing tables | 7 | 46922000 | 6703000 | |
| 85 | + * | hal | stage/sql/System lock | 6 | 40175000 | 6695000 | |
| 86 | + * | hal | stage/sql/query end | 7 | 31723000 | 4531000 | |
| 87 | + * | hal | stage/sql/Sorting result | 6 | 9855000 | 1642000 | |
| 88 | + * | hal | stage/sql/end | 6 | 9556000 | 1592000 | |
| 89 | + * | hal | stage/sql/cleaning up | 7 | 7312000 | 1044000 | |
| 90 | + * | hal | stage/sql/executing | 6 | 6487000 | 1081000 | |
| 91 | + * +------+--------------------------------+-------+-------------+-----------+ * |
| 92 | + */ |
| 93 | + |
| 94 | +CREATE OR REPLACE |
| 95 | + ALGORITHM = MERGE |
| 96 | + DEFINER = 'root'@'localhost' |
| 97 | + SQL SECURITY INVOKER |
| 98 | +VIEW x$host_summary_by_stages ( |
| 99 | + host, |
| 100 | + event_name, |
| 101 | + total, |
| 102 | + wait_sum, |
| 103 | + wait_avg |
| 104 | +) AS |
| 105 | +SELECT host, |
| 106 | + event_name, |
| 107 | + count_star AS total, |
| 108 | + sum_timer_wait AS wait_sum, |
| 109 | + avg_timer_wait AS wait_avg |
| 110 | + FROM performance_schema.events_stages_summary_by_host_by_event_name |
| 111 | + WHERE host IS NOT NULL |
| 112 | + AND sum_timer_wait != 0 |
| 113 | + ORDER BY host, sum_timer_wait DESC; |
0 commit comments