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

Commit c1167b5

Browse files
committed
Merge pull request #9 from joegrasse/master
Merge fixes for Issue #1 and Issue #6, contribution from Joe Grasse (Thanks!)
2 parents 65d27e4 + 6ece096 commit c1167b5

19 files changed

+83
-83
lines changed

sys_56.sql

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
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 */
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
1515

1616
SOURCE ./before_setup.sql
1717

sys_57.sql

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
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 */
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
1515

1616
SOURCE ./before_setup.sql
1717

views/i_s/innodb_buffer_stats_by_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
9292
COUNT(ibp.page_number) AS pages,
9393
COUNT(IF(ibp.is_hashed = 'YES', 1, 0)) AS pages_hashed,
9494
COUNT(IF(ibp.is_old = 'YES', 1, 0)) AS pages_old,
95-
ROUND(SUM(ibp.number_records)/COUNT(DISTINCT ibp.index_name)) AS rows_cached
95+
ROUND(IFNULL(SUM(ibp.number_records)/NULLIF(COUNT(DISTINCT ibp.index_name), 0), 0)) AS rows_cached
9696
FROM information_schema.innodb_buffer_page ibp
9797
WHERE table_name IS NOT NULL
9898
GROUP BY object_schema

views/i_s/innodb_buffer_stats_by_table.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_IN
104104
COUNT(ibp.page_number) AS pages,
105105
COUNT(IF(ibp.is_hashed = 'YES', 1, 0)) AS pages_hashed,
106106
COUNT(IF(ibp.is_old = 'YES', 1, 0)) AS pages_old,
107-
ROUND(SUM(ibp.number_records)/COUNT(DISTINCT ibp.index_name)) AS rows_cached
107+
ROUND(IFNULL(SUM(ibp.number_records)/NULLIF(COUNT(DISTINCT ibp.index_name), 0), 0)) AS rows_cached
108108
FROM information_schema.innodb_buffer_page ibp
109109
WHERE table_name IS NOT NULL
110110
GROUP BY object_schema, object_name

views/p_s/io_global_by_file_by_bytes.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ VIEW io_global_by_file_by_bytes (
4949
SELECT sys.format_path(file_name) AS file,
5050
count_read,
5151
sys.format_bytes(sum_number_of_bytes_read) AS total_read,
52-
sys.format_bytes(IFNULL(sum_number_of_bytes_read / count_read, 0)) AS avg_read,
52+
sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
5353
count_write,
5454
sys.format_bytes(sum_number_of_bytes_write) AS total_written,
55-
sys.format_bytes(IFNULL(sum_number_of_bytes_write / count_write, 0.00)) AS avg_write,
55+
sys.format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0.00)) AS avg_write,
5656
sys.format_bytes(sum_number_of_bytes_read + sum_number_of_bytes_write) AS total,
57-
IFNULL(ROUND(100-((sum_number_of_bytes_read/(sum_number_of_bytes_read+sum_number_of_bytes_write))*100), 2), 0.00) AS write_pct
57+
IFNULL(ROUND(100-((sum_number_of_bytes_read/ NULLIF((sum_number_of_bytes_read+sum_number_of_bytes_write), 0))*100), 2), 0.00) AS write_pct
5858
FROM performance_schema.file_summary_by_instance
5959
ORDER BY sum_number_of_bytes_read + sum_number_of_bytes_write DESC;
6060

@@ -94,11 +94,11 @@ VIEW x$io_global_by_file_by_bytes (
9494
SELECT file_name AS file,
9595
count_read,
9696
sum_number_of_bytes_read AS total_read,
97-
IFNULL(sum_number_of_bytes_read / count_read, 0) AS avg_read,
97+
IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0) AS avg_read,
9898
count_write,
9999
sum_number_of_bytes_write AS total_written,
100-
IFNULL(sum_number_of_bytes_write / count_write, 0.00) AS avg_write,
100+
IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0.00) AS avg_write,
101101
sum_number_of_bytes_read + sum_number_of_bytes_write AS total,
102-
IFNULL(ROUND(100-((sum_number_of_bytes_read/(sum_number_of_bytes_read+sum_number_of_bytes_write))*100), 2), 0.00) AS write_pct
102+
IFNULL(ROUND(100-((sum_number_of_bytes_read/ NULLIF((sum_number_of_bytes_read+sum_number_of_bytes_write), 0))*100), 2), 0.00) AS write_pct
103103
FROM performance_schema.file_summary_by_instance
104104
ORDER BY sum_number_of_bytes_read + sum_number_of_bytes_write DESC;

views/p_s/io_global_by_wait_by_bytes.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ SELECT SUBSTRING_INDEX(event_name, '/', -2) event_name,
6969
sys.format_time(max_timer_wait) AS max_latency,
7070
count_read,
7171
sys.format_bytes(sum_number_of_bytes_read) AS total_read,
72-
sys.format_bytes(IFNULL(sum_number_of_bytes_read / count_read, 0)) AS avg_read,
72+
sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
7373
count_write,
7474
sys.format_bytes(sum_number_of_bytes_write) AS total_written,
75-
sys.format_bytes(IFNULL(sum_number_of_bytes_write / count_write, 0)) AS avg_written,
75+
sys.format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0)) AS avg_written,
7676
sys.format_bytes(sum_number_of_bytes_write + sum_number_of_bytes_read) AS total_requested
7777
FROM performance_schema.file_summary_by_event_name
7878
WHERE event_name LIKE 'wait/io/file/%'
@@ -130,10 +130,10 @@ SELECT SUBSTRING_INDEX(event_name, '/', -2) AS event_name,
130130
max_timer_wait AS max_latency,
131131
count_read,
132132
sum_number_of_bytes_read AS total_read,
133-
IFNULL(sum_number_of_bytes_read / count_read, 0) AS avg_read,
133+
IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0) AS avg_read,
134134
count_write,
135135
sum_number_of_bytes_write AS total_written,
136-
IFNULL(sum_number_of_bytes_write / count_write, 0) AS avg_written,
136+
IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0) AS avg_written,
137137
sum_number_of_bytes_write + sum_number_of_bytes_read AS total_requested
138138
FROM performance_schema.file_summary_by_event_name
139139
WHERE event_name LIKE 'wait/io/file/%'

views/p_s/io_global_by_wait_by_latency.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ SELECT SUBSTRING_INDEX(event_name, '/', -2) AS event_name,
7272
sys.format_time(sum_timer_misc) AS misc_latency,
7373
count_read,
7474
sys.format_bytes(sum_number_of_bytes_read) AS total_read,
75-
sys.format_bytes(IFNULL(sum_number_of_bytes_read / count_read, 0)) AS avg_read,
75+
sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
7676
count_write,
7777
sys.format_bytes(sum_number_of_bytes_write) AS total_written,
78-
sys.format_bytes(IFNULL(sum_number_of_bytes_write / count_write, 0)) AS avg_written
78+
sys.format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0)) AS avg_written
7979
FROM performance_schema.file_summary_by_event_name
8080
WHERE event_name LIKE 'wait/io/file/%'
8181
AND count_star > 0
@@ -141,10 +141,10 @@ SELECT SUBSTRING_INDEX(event_name, '/', -2) AS event_name,
141141
sum_timer_misc AS misc_latency,
142142
count_read,
143143
sum_number_of_bytes_read AS total_read,
144-
IFNULL(sum_number_of_bytes_read / count_read, 0) AS avg_read,
144+
IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0) AS avg_read,
145145
count_write,
146146
sum_number_of_bytes_write AS total_written,
147-
IFNULL(sum_number_of_bytes_write / count_write, 0) AS avg_written
147+
IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0) AS avg_written
148148
FROM performance_schema.file_summary_by_event_name
149149
WHERE event_name LIKE 'wait/io/file/%'
150150
AND count_star > 0

views/p_s/memory_by_user.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ VIEW memory_by_user_by_current_bytes (
4343
SELECT user,
4444
SUM(current_count_used) AS current_count_used,
4545
sys.format_bytes(SUM(current_number_of_bytes_used)) AS current_allocated,
46-
sys.format_bytes(SUM(current_number_of_bytes_used) / SUM(current_count_used)) AS current_avg_alloc,
46+
sys.format_bytes(IFNULL(SUM(current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
4747
sys.format_bytes(MAX(current_number_of_bytes_used)) AS current_max_alloc,
4848
sys.format_bytes(SUM(sum_number_of_bytes_alloc)) AS total_allocated
4949
FROM performance_schema.memory_summary_by_user_by_event_name
@@ -80,7 +80,7 @@ VIEW x$memory_by_user_by_current_bytes (
8080
SELECT user,
8181
SUM(current_count_used) AS current_count_used,
8282
SUM(current_number_of_bytes_used) AS current_allocated,
83-
SUM(current_number_of_bytes_used) / SUM(current_count_used) AS current_avg_alloc,
83+
IFNULL(SUM(current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0) AS current_avg_alloc,
8484
MAX(current_number_of_bytes_used) AS current_max_alloc,
8585
SUM(sum_number_of_bytes_alloc) AS total_allocated
8686
FROM performance_schema.memory_summary_by_user_by_event_name

views/p_s/memory_global_by_current_allocated.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ VIEW memory_global_by_current_allocated (
4848
SELECT event_name,
4949
current_count_used AS current_count,
5050
sys.format_bytes(current_number_of_bytes_used) AS current_alloc,
51-
sys.format_bytes(current_number_of_bytes_used / current_count_used) AS current_avg_alloc,
51+
sys.format_bytes(IFNULL(current_number_of_bytes_used / NULLIF(current_count_used, 0), 0)) AS current_avg_alloc,
5252
high_count_used AS high_count,
5353
sys.format_bytes(high_number_of_bytes_used) AS high_alloc,
54-
sys.format_bytes(high_number_of_bytes_used / high_count_used) AS high_avg_alloc
54+
sys.format_bytes(IFNULL(high_number_of_bytes_used / NULLIF(high_count_used, 0), 0)) AS high_avg_alloc
5555
FROM performance_schema.memory_summary_global_by_event_name
5656
WHERE current_number_of_bytes_used > 0
5757
ORDER BY current_number_of_bytes_used DESC;
@@ -91,10 +91,10 @@ VIEW x$memory_global_by_current_allocated (
9191
SELECT event_name,
9292
current_count_used AS current_count,
9393
current_number_of_bytes_used AS current_alloc,
94-
current_number_of_bytes_used / current_count_used AS current_avg_alloc,
94+
IFNULL(current_number_of_bytes_used / NULLIF(current_count_used, 0), 0) AS current_avg_alloc,
9595
high_count_used AS high_count,
9696
high_number_of_bytes_used AS high_alloc,
97-
high_number_of_bytes_used / high_count_used AS high_avg_alloc
97+
IFNULL(high_number_of_bytes_used / NULLIF(high_count_used, 0), 0) AS high_avg_alloc
9898
FROM performance_schema.memory_summary_global_by_event_name
9999
WHERE current_number_of_bytes_used > 0
100100
ORDER BY current_number_of_bytes_used DESC;

views/p_s/statement_analysis.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ SELECT sys.format_statement(DIGEST_TEXT) AS query,
8484
sys.format_time(AVG_TIMER_WAIT) AS avg_latency,
8585
sys.format_time(SUM_LOCK_TIME) AS lock_latency,
8686
SUM_ROWS_SENT AS rows_sent,
87-
ROUND(SUM_ROWS_SENT / COUNT_STAR) AS rows_sent_avg,
87+
ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,
8888
SUM_ROWS_EXAMINED AS rows_examined,
89-
ROUND(SUM_ROWS_EXAMINED / COUNT_STAR) AS rows_examined_avg,
89+
ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,
9090
SUM_CREATED_TMP_TABLES AS tmp_tables,
9191
SUM_CREATED_TMP_DISK_TABLES AS tmp_disk_tables,
9292
SUM_SORT_ROWS AS rows_sorted,
@@ -168,9 +168,9 @@ SELECT DIGEST_TEXT AS query,
168168
AVG_TIMER_WAIT AS avg_latency,
169169
SUM_LOCK_TIME AS lock_latency,
170170
SUM_ROWS_SENT AS rows_sent,
171-
ROUND(SUM_ROWS_SENT / COUNT_STAR) AS rows_sent_avg,
171+
ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,
172172
SUM_ROWS_EXAMINED AS rows_examined,
173-
ROUND(SUM_ROWS_EXAMINED / COUNT_STAR) AS rows_examined_avg,
173+
ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,
174174
SUM_CREATED_TMP_TABLES AS tmp_tables,
175175
SUM_CREATED_TMP_DISK_TABLES AS tmp_disk_tables,
176176
SUM_SORT_ROWS AS rows_sorted,

0 commit comments

Comments
 (0)