|
| 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 |
| 18 | + * |
| 19 | + * Summarizes statement activity and connections by host |
| 20 | + * |
| 21 | + * mysql> select * from host_summary; |
| 22 | + * +------+------------+---------------+-------------+---------------------+-------------------+--------------+----------------+------------------------+ |
| 23 | + * | host | statements | total_latency | avg_latency | current_connections | total_connections | unique_users | current_memory | total_memory_allocated | |
| 24 | + * +------+------------+---------------+-------------+---------------------+-------------------+--------------+----------------+------------------------+ |
| 25 | + * | hal1 | 5663 | 00:01:47.14 | 18.92 ms | 1 | 1 | 1 | 1.41 MiB | 543.55 MiB | |
| 26 | + * | hal2 | 225 | 14.49 s | 64.40 ms | 1 | 1 | 1 | 707.60 KiB | 81.02 MiB | |
| 27 | + * +------+------------+---------------+-------------+---------------------+-------------------+--------------+----------------+------------------------+ |
| 28 | + * |
| 29 | + */ |
| 30 | + |
| 31 | +CREATE OR REPLACE |
| 32 | + ALGORITHM = TEMPTABLE |
| 33 | + DEFINER = 'root'@'localhost' |
| 34 | + SQL SECURITY INVOKER |
| 35 | +VIEW host_summary ( |
| 36 | + host, |
| 37 | + statements, |
| 38 | + statement_latency, |
| 39 | + statement_avg_latency, |
| 40 | + table_scans, |
| 41 | + file_ios, |
| 42 | + file_io_latency, |
| 43 | + current_connections, |
| 44 | + total_connections, |
| 45 | + unique_hosts, |
| 46 | + current_memory, |
| 47 | + total_memory_allocated |
| 48 | +) AS |
| 49 | +SELECT accounts.host, |
| 50 | + SUM(stmt.total) AS statements, |
| 51 | + sys.format_time(SUM(stmt.total_latency)) AS statement_latency, |
| 52 | + sys.format_time(SUM(stmt.total_latency) / SUM(stmt.total)) AS statement_avg_latency, |
| 53 | + SUM(stmt.full_scans) AS table_scans, |
| 54 | + SUM(io.ios) AS file_ios, |
| 55 | + sys.format_time(SUM(io.io_latency)) AS file_io_latency, |
| 56 | + SUM(accounts.current_connections) AS current_connections, |
| 57 | + SUM(accounts.total_connections) AS total_connections, |
| 58 | + 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 | + FROM performance_schema.accounts |
| 62 | + JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host |
| 63 | + JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host |
| 64 | + 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 | + |
| 68 | +/* |
| 69 | + * View: x$host_summary |
| 70 | + * |
| 71 | + * Summarizes statement activity and connections by host |
| 72 | + * |
| 73 | + * mysql> select * from x$host_summary; |
| 74 | + * +------+------------+-----------------+------------------+---------------------+-------------------+--------------+----------------+------------------------+ |
| 75 | + * | host | statements | total_latency | avg_latency | current_connections | total_connections | unique_users | current_memory | total_memory_allocated | |
| 76 | + * +------+------------+-----------------+------------------+---------------------+-------------------+--------------+----------------+------------------------+ |
| 77 | + * | hal1 | 5685 | 107175100271000 | 18852260381.8821 | 1 | 1 | 1 | 1459022 | 572855680 | |
| 78 | + * | hal2 | 225 | 14489223428000 | 64396548568.8889 | 1 | 1 | 1 | 724578 | 84958286 | |
| 79 | + * +------+------------+-----------------+------------------+---------------------+-------------------+--------------+----------------+------------------------+ |
| 80 | + * |
| 81 | + */ |
| 82 | + |
| 83 | +CREATE OR REPLACE |
| 84 | + ALGORITHM = TEMPTABLE |
| 85 | + DEFINER = 'root'@'localhost' |
| 86 | + SQL SECURITY INVOKER |
| 87 | +VIEW x$host_summary ( |
| 88 | + host, |
| 89 | + statements, |
| 90 | + statement_latency, |
| 91 | + statement_avg_latency, |
| 92 | + table_scans, |
| 93 | + file_ios, |
| 94 | + file_io_latency, |
| 95 | + current_connections, |
| 96 | + total_connections, |
| 97 | + unique_users, |
| 98 | + current_memory, |
| 99 | + total_memory_allocated |
| 100 | +) AS |
| 101 | +SELECT accounts.host, |
| 102 | + SUM(stmt.total) AS statements, |
| 103 | + SUM(stmt.total_latency) AS statement_latency, |
| 104 | + SUM(stmt.total_latency) / SUM(stmt.total) AS statement_avg_latency, |
| 105 | + SUM(stmt.full_scans) AS table_scans, |
| 106 | + SUM(io.ios) AS file_ios, |
| 107 | + SUM(io.io_latency) AS file_io_latency, |
| 108 | + SUM(accounts.current_connections) AS current_connections, |
| 109 | + SUM(accounts.total_connections) AS total_connections, |
| 110 | + COUNT(DISTINCT accounts.user) AS unique_users, |
| 111 | + mem.current_allocated AS current_memory, |
| 112 | + mem.total_allocated AS total_memory_allocated |
| 113 | + FROM performance_schema.accounts |
| 114 | + JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host |
| 115 | + JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host |
| 116 | + 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; |
0 commit comments