mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 17:54:16 +01:00
MDEV-31736: format_bytes implementation
This commit is contained in:
parent
f24d08df96
commit
a35f744d78
44 changed files with 600 additions and 117 deletions
|
@ -1,6 +1,6 @@
|
|||
# MDEV-19629: Implement MySQL 8.0 native functions: format_bytes(), format_pico_time() and ps_thread_id()
|
||||
#
|
||||
# Tests for the Performance Schema native function format_pico_time()
|
||||
# Tests for the native function format_pico_time()
|
||||
#
|
||||
|
||||
SELECT format_pico_time(NULL);
|
||||
|
@ -211,3 +211,222 @@ format_pico_time(5e3)
|
|||
SELECT format_pico_time(6e2);
|
||||
format_pico_time(6e2)
|
||||
600 ps
|
||||
#
|
||||
# Start of 11.8 tests
|
||||
#
|
||||
#
|
||||
# MDEV-19629 Tests for the native function format_bytes()
|
||||
#
|
||||
|
||||
SELECT format_bytes(NULL);
|
||||
format_bytes(NULL)
|
||||
NULL
|
||||
|
||||
SELECT format_bytes(0);
|
||||
format_bytes(0)
|
||||
0 bytes
|
||||
|
||||
SELECT format_bytes(1);
|
||||
format_bytes(1)
|
||||
1 bytes
|
||||
|
||||
SELECT format_bytes(1023);
|
||||
format_bytes(1023)
|
||||
1023 bytes
|
||||
|
||||
SELECT format_bytes(1024);
|
||||
format_bytes(1024)
|
||||
1.00 KiB
|
||||
|
||||
SELECT format_bytes(1025);
|
||||
format_bytes(1025)
|
||||
1.00 KiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 - 200);
|
||||
format_bytes(1024 * 1024 - 200)
|
||||
1023.80 KiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 - 1);
|
||||
format_bytes(1024 * 1024 - 1)
|
||||
1024.00 KiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024);
|
||||
format_bytes(1024 * 1024)
|
||||
1.00 MiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 + 1);
|
||||
format_bytes(1024 * 1024 + 1)
|
||||
1.00 MiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 + 200);
|
||||
format_bytes(1024 * 1024 + 200)
|
||||
1.00 MiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 - 1);
|
||||
format_bytes(1024 * 1024 * 1024 - 1)
|
||||
1024.00 MiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024);
|
||||
format_bytes(1024 * 1024 * 1024)
|
||||
1.00 GiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 + 1);
|
||||
format_bytes(1024 * 1024 * 1024 + 1)
|
||||
1.00 GiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 - 1);
|
||||
format_bytes(1024 * 1024 * 1024 * 1024 - 1)
|
||||
1024.00 GiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024);
|
||||
format_bytes(1024 * 1024 * 1024 * 1024)
|
||||
1.00 TiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 + 1);
|
||||
format_bytes(1024 * 1024 * 1024 * 1024 + 1)
|
||||
1.00 TiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024 - 1);
|
||||
format_bytes(1024 * 1024 * 1024 * 1024 * 1024 - 1)
|
||||
1024.00 TiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024);
|
||||
format_bytes(1024 * 1024 * 1024 * 1024 * 1024)
|
||||
1.00 PiB
|
||||
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024 + 1);
|
||||
format_bytes(1024 * 1024 * 1024 * 1024 * 1024 + 1)
|
||||
1.00 PiB
|
||||
|
||||
SELECT format_bytes(power(2, 63));
|
||||
format_bytes(power(2, 63))
|
||||
8.00 EiB
|
||||
|
||||
## 1024^6 Eib
|
||||
SELECT format_bytes(1152921504606846976-1);
|
||||
format_bytes(1152921504606846976-1)
|
||||
1.00 EiB
|
||||
|
||||
SELECT format_bytes(1180591620717411434000);
|
||||
format_bytes(1180591620717411434000)
|
||||
1024.00 EiB
|
||||
|
||||
## Negative values are ok
|
||||
SELECT format_bytes(1024 * 1024 * -1);
|
||||
format_bytes(1024 * 1024 * -1)
|
||||
-1.00 MiB
|
||||
|
||||
## Force exponent format
|
||||
SELECT format_bytes(118059162071741143500099);
|
||||
format_bytes(118059162071741143500099)
|
||||
1.02e+05 EiB
|
||||
|
||||
SELECT format_bytes(-118059162071741143500099);
|
||||
format_bytes(-118059162071741143500099)
|
||||
-1.02e+05 EiB
|
||||
|
||||
SELECT format_bytes(pow(2,400));
|
||||
format_bytes(pow(2,400))
|
||||
2.24e+102 EiB
|
||||
|
||||
## Valid hybrid number
|
||||
SELECT format_bytes((pow(2, 63) - 1) * 2 + 1);
|
||||
format_bytes((pow(2, 63) - 1) * 2 + 1)
|
||||
16.00 EiB
|
||||
|
||||
## Text input
|
||||
SELECT format_bytes("foo");
|
||||
format_bytes("foo")
|
||||
0 bytes
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
|
||||
|
||||
SELECT format_bytes("");
|
||||
format_bytes("")
|
||||
0 bytes
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: ''
|
||||
|
||||
SELECT format_bytes("118059162071741143500099");
|
||||
format_bytes("118059162071741143500099")
|
||||
1.02e+05 EiB
|
||||
|
||||
SELECT format_bytes("-118059162071741143500099");
|
||||
format_bytes("-118059162071741143500099")
|
||||
-1.02e+05 EiB
|
||||
|
||||
## Recognizes up to first non-numeric
|
||||
SELECT format_bytes("40000 * 2000");
|
||||
format_bytes("40000 * 2000")
|
||||
39.06 KiB
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '40000 * 2000'
|
||||
|
||||
SELECT format_bytes("40000 foo 2000");
|
||||
format_bytes("40000 foo 2000")
|
||||
39.06 KiB
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '40000 foo 2000'
|
||||
## Aggregate functions
|
||||
USE test;
|
||||
|
||||
CREATE TABLE memory_counts (id VARCHAR(10), bytes BIGINT UNSIGNED DEFAULT NULL) DEFAULT CHARSET = utf8mb4;
|
||||
|
||||
INSERT INTO memory_counts VALUES ('Bytes', 512);
|
||||
INSERT INTO memory_counts VALUES ('10 KiB', 10 * 1024);
|
||||
INSERT INTO memory_counts VALUES ('20 MiB', 20 * pow(1024,2));
|
||||
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
sum(bytes) format_bytes(sum(bytes))
|
||||
20982272 20.01 MiB
|
||||
|
||||
INSERT INTO memory_counts VALUES ('30 GiB', 30 * pow(1024,3));
|
||||
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
sum(bytes) format_bytes(sum(bytes))
|
||||
32233236992 30.02 GiB
|
||||
|
||||
INSERT INTO memory_counts VALUES ('40 TiB', 40 * pow(1024,4));
|
||||
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
sum(bytes) format_bytes(sum(bytes))
|
||||
44012698348032 40.03 TiB
|
||||
|
||||
INSERT INTO memory_counts VALUES ('50 PiB', 50 * pow(1024,5));
|
||||
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
sum(bytes) format_bytes(sum(bytes))
|
||||
56339008040479232 50.04 PiB
|
||||
|
||||
INSERT INTO memory_counts VALUES ('1 EiB', pow(1024,6));
|
||||
|
||||
SELECT id, format_bytes(bytes), bytes FROM memory_counts;
|
||||
id format_bytes(bytes) bytes
|
||||
Bytes 512 bytes 512
|
||||
10 KiB 10.00 KiB 10240
|
||||
20 MiB 20.00 MiB 20971520
|
||||
30 GiB 30.00 GiB 32212254720
|
||||
40 TiB 40.00 TiB 43980465111040
|
||||
50 PiB 50.00 PiB 56294995342131200
|
||||
1 EiB 1.00 EiB 1152921504606846976
|
||||
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
sum(bytes) format_bytes(sum(bytes))
|
||||
1209260512647326208 1.05 EiB
|
||||
|
||||
SELECT avg(bytes), format_bytes(avg(bytes)) FROM memory_counts;
|
||||
avg(bytes) format_bytes(avg(bytes))
|
||||
172751501806760886.8571 153.43 PiB
|
||||
|
||||
SELECT max(bytes), format_bytes(max(bytes)) FROM memory_counts;
|
||||
max(bytes) format_bytes(max(bytes))
|
||||
1152921504606846976 1.00 EiB
|
||||
|
||||
SELECT min(bytes), format_bytes(min(bytes)) FROM memory_counts;
|
||||
min(bytes) format_bytes(min(bytes))
|
||||
512 512 bytes
|
||||
|
||||
DROP TABLE memory_counts;
|
||||
#
|
||||
# End of 11.8 tests
|
||||
#
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
--echo # MDEV-19629: Implement MySQL 8.0 native functions: format_bytes(), format_pico_time() and ps_thread_id()
|
||||
--echo #
|
||||
--echo # Tests for the Performance Schema native function format_pico_time()
|
||||
--echo # Tests for the native function format_pico_time()
|
||||
--echo #
|
||||
--echo
|
||||
|
||||
|
@ -118,3 +118,138 @@ SELECT format_pico_time(4e6);
|
|||
SELECT format_pico_time(5e3);
|
||||
--echo
|
||||
SELECT format_pico_time(6e2);
|
||||
|
||||
--echo #
|
||||
--echo # Start of 11.8 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19629 Tests for the native function format_bytes()
|
||||
--echo #
|
||||
--echo
|
||||
|
||||
SELECT format_bytes(NULL);
|
||||
--echo
|
||||
SELECT format_bytes(0);
|
||||
--echo
|
||||
SELECT format_bytes(1);
|
||||
--echo
|
||||
SELECT format_bytes(1023);
|
||||
--echo
|
||||
SELECT format_bytes(1024);
|
||||
--echo
|
||||
SELECT format_bytes(1025);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 - 200);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 - 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 + 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 + 200);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 - 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 + 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 - 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 + 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024 - 1);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024);
|
||||
--echo
|
||||
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024 + 1);
|
||||
--echo
|
||||
SELECT format_bytes(power(2, 63));
|
||||
|
||||
--echo
|
||||
--echo ## 1024^6 Eib
|
||||
SELECT format_bytes(1152921504606846976-1);
|
||||
|
||||
--echo
|
||||
SELECT format_bytes(1180591620717411434000);
|
||||
|
||||
--echo
|
||||
--echo ## Negative values are ok
|
||||
SELECT format_bytes(1024 * 1024 * -1);
|
||||
|
||||
--echo
|
||||
--echo ## Force exponent format
|
||||
SELECT format_bytes(118059162071741143500099);
|
||||
--echo
|
||||
SELECT format_bytes(-118059162071741143500099);
|
||||
--echo
|
||||
SELECT format_bytes(pow(2,400));
|
||||
|
||||
--echo
|
||||
--echo ## Valid hybrid number
|
||||
SELECT format_bytes((pow(2, 63) - 1) * 2 + 1);
|
||||
|
||||
--echo
|
||||
--echo ## Text input
|
||||
SELECT format_bytes("foo");
|
||||
--echo
|
||||
SELECT format_bytes("");
|
||||
--echo
|
||||
SELECT format_bytes("118059162071741143500099");
|
||||
--echo
|
||||
SELECT format_bytes("-118059162071741143500099");
|
||||
--echo
|
||||
--echo ## Recognizes up to first non-numeric
|
||||
SELECT format_bytes("40000 * 2000");
|
||||
--echo
|
||||
SELECT format_bytes("40000 foo 2000");
|
||||
|
||||
--echo ## Aggregate functions
|
||||
USE test;
|
||||
--echo
|
||||
CREATE TABLE memory_counts (id VARCHAR(10), bytes BIGINT UNSIGNED DEFAULT NULL) DEFAULT CHARSET = utf8mb4;
|
||||
--echo
|
||||
# Max BIGINT unsigned is 18 446 744 073 709 551 615
|
||||
INSERT INTO memory_counts VALUES ('Bytes', 512);
|
||||
INSERT INTO memory_counts VALUES ('10 KiB', 10 * 1024);
|
||||
INSERT INTO memory_counts VALUES ('20 MiB', 20 * pow(1024,2));
|
||||
--echo
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
|
||||
--echo
|
||||
INSERT INTO memory_counts VALUES ('30 GiB', 30 * pow(1024,3));
|
||||
--echo
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
|
||||
--echo
|
||||
INSERT INTO memory_counts VALUES ('40 TiB', 40 * pow(1024,4));
|
||||
--echo
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
|
||||
--echo
|
||||
INSERT INTO memory_counts VALUES ('50 PiB', 50 * pow(1024,5));
|
||||
--echo
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
|
||||
--echo
|
||||
INSERT INTO memory_counts VALUES ('1 EiB', pow(1024,6));
|
||||
--echo
|
||||
SELECT id, format_bytes(bytes), bytes FROM memory_counts;
|
||||
--echo
|
||||
SELECT sum(bytes), format_bytes(sum(bytes)) FROM memory_counts;
|
||||
--echo
|
||||
SELECT avg(bytes), format_bytes(avg(bytes)) FROM memory_counts;
|
||||
--echo
|
||||
SELECT max(bytes), format_bytes(max(bytes)) FROM memory_counts;
|
||||
--echo
|
||||
SELECT min(bytes), format_bytes(min(bytes)) FROM memory_counts;
|
||||
--echo
|
||||
DROP TABLE memory_counts;
|
||||
|
||||
--echo #
|
||||
--echo # End of 11.8 tests
|
||||
--echo #
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
SELECT sys.format_bytes(NULL);
|
||||
sys.format_bytes(NULL)
|
||||
NULL
|
||||
Warnings:
|
||||
Note 1585 This function 'format_bytes' has the same name as a native function
|
||||
SELECT sys.format_bytes(1);
|
||||
sys.format_bytes(1)
|
||||
1 bytes
|
||||
|
|
|
@ -10,8 +10,8 @@ file_io_latency varchar(12) YES NULL
|
|||
current_connections decimal(41,0) YES NULL
|
||||
total_connections decimal(41,0) YES NULL
|
||||
unique_users bigint(21) NO 0
|
||||
current_memory text YES NULL
|
||||
total_memory_allocated text YES NULL
|
||||
current_memory varchar(14) YES NULL
|
||||
total_memory_allocated varchar(14) YES NULL
|
||||
SELECT * FROM sys.host_summary;
|
||||
DESC sys.x$host_summary;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
DESC sys.innodb_buffer_stats_by_schema;
|
||||
Field Type Null Key Default Extra
|
||||
object_schema text YES NULL
|
||||
allocated text YES NULL
|
||||
data text YES NULL
|
||||
allocated varchar(14) YES NULL
|
||||
data varchar(14) YES NULL
|
||||
pages bigint(21) NO 0
|
||||
pages_hashed bigint(21) NO 0
|
||||
pages_old bigint(21) NO 0
|
||||
|
|
|
@ -2,8 +2,8 @@ DESC sys.innodb_buffer_stats_by_table;
|
|||
Field Type Null Key Default Extra
|
||||
object_schema text YES NULL
|
||||
object_name text YES NULL
|
||||
allocated text YES NULL
|
||||
data text YES NULL
|
||||
allocated varchar(14) YES NULL
|
||||
data varchar(14) YES NULL
|
||||
pages bigint(21) NO 0
|
||||
pages_hashed bigint(21) NO 0
|
||||
pages_old bigint(21) NO 0
|
||||
|
|
|
@ -2,12 +2,12 @@ DESC sys.io_global_by_file_by_bytes;
|
|||
Field Type Null Key Default Extra
|
||||
file varchar(512) YES NULL
|
||||
count_read bigint(20) unsigned NO NULL
|
||||
total_read text YES NULL
|
||||
avg_read text YES NULL
|
||||
total_read varchar(14) YES NULL
|
||||
avg_read varchar(14) YES NULL
|
||||
count_write bigint(20) unsigned NO NULL
|
||||
total_written text YES NULL
|
||||
avg_write text YES NULL
|
||||
total text YES NULL
|
||||
total_written varchar(14) YES NULL
|
||||
avg_write varchar(14) YES NULL
|
||||
total varchar(14) YES NULL
|
||||
write_pct decimal(26,2) NO 0.00
|
||||
SELECT * FROM sys.io_global_by_file_by_bytes;
|
||||
DESC sys.x$io_global_by_file_by_bytes;
|
||||
|
|
|
@ -7,12 +7,12 @@ min_latency varchar(12) YES NULL
|
|||
avg_latency varchar(12) YES NULL
|
||||
max_latency varchar(12) YES NULL
|
||||
count_read bigint(20) unsigned NO NULL
|
||||
total_read text YES NULL
|
||||
avg_read text YES NULL
|
||||
total_read varchar(14) YES NULL
|
||||
avg_read varchar(14) YES NULL
|
||||
count_write bigint(20) unsigned NO NULL
|
||||
total_written text YES NULL
|
||||
avg_written text YES NULL
|
||||
total_requested text YES NULL
|
||||
total_written varchar(14) YES NULL
|
||||
avg_written varchar(14) YES NULL
|
||||
total_requested varchar(14) YES NULL
|
||||
SELECT * FROM sys.io_global_by_wait_by_bytes;
|
||||
DESC sys.x$io_global_by_wait_by_bytes;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -9,11 +9,11 @@ read_latency varchar(12) YES NULL
|
|||
write_latency varchar(12) YES NULL
|
||||
misc_latency varchar(12) YES NULL
|
||||
count_read bigint(20) unsigned NO NULL
|
||||
total_read text YES NULL
|
||||
avg_read text YES NULL
|
||||
total_read varchar(14) YES NULL
|
||||
avg_read varchar(14) YES NULL
|
||||
count_write bigint(20) unsigned NO NULL
|
||||
total_written text YES NULL
|
||||
avg_written text YES NULL
|
||||
total_written varchar(14) YES NULL
|
||||
avg_written varchar(14) YES NULL
|
||||
SELECT * FROM sys.io_global_by_wait_by_latency;
|
||||
DESC sys.x$io_global_by_wait_by_latency;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -4,7 +4,7 @@ thread varchar(214) YES NULL
|
|||
file varchar(512) YES NULL
|
||||
latency varchar(12) YES NULL
|
||||
operation varchar(32) NO NULL
|
||||
requested text YES NULL
|
||||
requested varchar(14) YES NULL
|
||||
SELECT * FROM sys.latest_file_io;
|
||||
DESC sys.x$latest_file_io;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -2,10 +2,10 @@ DESC sys.memory_by_host_by_current_bytes;
|
|||
Field Type Null Key Default Extra
|
||||
host varchar(60) YES NULL
|
||||
current_count_used decimal(41,0) YES NULL
|
||||
current_allocated text YES NULL
|
||||
current_avg_alloc text YES NULL
|
||||
current_max_alloc text YES NULL
|
||||
total_allocated text YES NULL
|
||||
current_allocated varchar(14) YES NULL
|
||||
current_avg_alloc varchar(14) YES NULL
|
||||
current_max_alloc varchar(14) YES NULL
|
||||
total_allocated varchar(14) YES NULL
|
||||
SELECT * FROM sys.memory_by_host_by_current_bytes;
|
||||
DESC sys.x$memory_by_host_by_current_bytes;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -3,10 +3,10 @@ Field Type Null Key Default Extra
|
|||
thread_id bigint(20) unsigned NO NULL
|
||||
user varchar(384) YES NULL
|
||||
current_count_used decimal(41,0) YES NULL
|
||||
current_allocated text YES NULL
|
||||
current_avg_alloc text YES NULL
|
||||
current_max_alloc text YES NULL
|
||||
total_allocated text YES NULL
|
||||
current_allocated varchar(14) YES NULL
|
||||
current_avg_alloc varchar(14) YES NULL
|
||||
current_max_alloc varchar(14) YES NULL
|
||||
total_allocated varchar(14) YES NULL
|
||||
SELECT * FROM sys.memory_by_thread_by_current_bytes;
|
||||
DESC sys.x$memory_by_thread_by_current_bytes;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -2,10 +2,10 @@ DESC sys.memory_by_user_by_current_bytes;
|
|||
Field Type Null Key Default Extra
|
||||
user varchar(32) YES NULL
|
||||
current_count_used decimal(41,0) YES NULL
|
||||
current_allocated text YES NULL
|
||||
current_avg_alloc text YES NULL
|
||||
current_max_alloc text YES NULL
|
||||
total_allocated text YES NULL
|
||||
current_allocated varchar(14) YES NULL
|
||||
current_avg_alloc varchar(14) YES NULL
|
||||
current_max_alloc varchar(14) YES NULL
|
||||
total_allocated varchar(14) YES NULL
|
||||
SELECT * FROM sys.memory_by_user_by_current_bytes;
|
||||
DESC sys.x$memory_by_user_by_current_bytes;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -2,11 +2,11 @@ DESC sys.memory_global_by_current_bytes;
|
|||
Field Type Null Key Default Extra
|
||||
event_name varchar(128) NO NULL
|
||||
current_count bigint(20) NO NULL
|
||||
current_alloc text YES NULL
|
||||
current_avg_alloc text YES NULL
|
||||
current_alloc varchar(14) YES NULL
|
||||
current_avg_alloc varchar(14) YES NULL
|
||||
high_count bigint(20) NO NULL
|
||||
high_alloc text YES NULL
|
||||
high_avg_alloc text YES NULL
|
||||
high_alloc varchar(14) YES NULL
|
||||
high_avg_alloc varchar(14) YES NULL
|
||||
SELECT * FROM sys.memory_global_by_current_bytes;
|
||||
DESC sys.x$memory_global_by_current_bytes;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DESC sys.memory_global_total;
|
||||
Field Type Null Key Default Extra
|
||||
total_allocated text YES NULL
|
||||
total_allocated varchar(14) YES NULL
|
||||
SELECT * FROM sys.memory_global_total;
|
||||
DESC sys.x$memory_global_total;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -19,7 +19,7 @@ tmp_disk_tables bigint(20) unsigned YES NULL
|
|||
full_scan varchar(3) YES NULL
|
||||
last_statement longtext YES NULL
|
||||
last_statement_latency varchar(12) YES NULL
|
||||
current_memory text YES NULL
|
||||
current_memory varchar(14) YES NULL
|
||||
last_wait varchar(128) YES NULL
|
||||
last_wait_latency varchar(13) YES NULL
|
||||
source varchar(64) YES NULL
|
||||
|
|
|
@ -12,10 +12,10 @@ update_latency varchar(12) YES NULL
|
|||
rows_deleted bigint(20) unsigned NO NULL
|
||||
delete_latency varchar(12) YES NULL
|
||||
io_read_requests decimal(42,0) YES NULL
|
||||
io_read text YES NULL
|
||||
io_read varchar(14) YES NULL
|
||||
io_read_latency varchar(12) YES NULL
|
||||
io_write_requests decimal(42,0) YES NULL
|
||||
io_write text YES NULL
|
||||
io_write varchar(14) YES NULL
|
||||
io_write_latency varchar(12) YES NULL
|
||||
io_misc_requests decimal(42,0) YES NULL
|
||||
io_misc_latency varchar(12) YES NULL
|
||||
|
|
|
@ -11,16 +11,16 @@ update_latency varchar(12) YES NULL
|
|||
rows_deleted bigint(20) unsigned NO NULL
|
||||
delete_latency varchar(12) YES NULL
|
||||
io_read_requests decimal(42,0) YES NULL
|
||||
io_read text YES NULL
|
||||
io_read varchar(14) YES NULL
|
||||
io_read_latency varchar(12) YES NULL
|
||||
io_write_requests decimal(42,0) YES NULL
|
||||
io_write text YES NULL
|
||||
io_write varchar(14) YES NULL
|
||||
io_write_latency varchar(12) YES NULL
|
||||
io_misc_requests decimal(42,0) YES NULL
|
||||
io_misc_latency varchar(12) YES NULL
|
||||
innodb_buffer_allocated text YES NULL
|
||||
innodb_buffer_data text YES NULL
|
||||
innodb_buffer_free text YES NULL
|
||||
innodb_buffer_allocated varchar(14) YES NULL
|
||||
innodb_buffer_data varchar(14) YES NULL
|
||||
innodb_buffer_free varchar(14) YES NULL
|
||||
innodb_buffer_pages bigint(21) YES 0
|
||||
innodb_buffer_pages_hashed bigint(21) YES 0
|
||||
innodb_buffer_pages_old bigint(21) YES 0
|
||||
|
|
|
@ -19,7 +19,7 @@ tmp_disk_tables bigint(20) unsigned YES NULL
|
|||
full_scan varchar(3) YES NULL
|
||||
last_statement longtext YES NULL
|
||||
last_statement_latency varchar(12) YES NULL
|
||||
current_memory text YES NULL
|
||||
current_memory varchar(14) YES NULL
|
||||
last_wait varchar(128) YES NULL
|
||||
last_wait_latency varchar(13) YES NULL
|
||||
source varchar(64) YES NULL
|
||||
|
|
|
@ -10,8 +10,8 @@ file_io_latency varchar(12) YES NULL
|
|||
current_connections decimal(41,0) YES NULL
|
||||
total_connections decimal(41,0) YES NULL
|
||||
unique_hosts bigint(21) NO 0
|
||||
current_memory text YES NULL
|
||||
total_memory_allocated text YES NULL
|
||||
current_memory varchar(14) YES NULL
|
||||
total_memory_allocated varchar(14) YES NULL
|
||||
SELECT * FROM sys.user_summary;
|
||||
DESC sys.x$user_summary;
|
||||
Field Type Null Key Default Extra
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
# Tests for sys schema
|
||||
# Verify the sys.format_bytes() function perfoms as expected
|
||||
|
||||
# Various protocols display ER_NATIVE_FCT_NAME_COLLISION very differently.
|
||||
# Disable all of them.
|
||||
|
||||
--disable_ps_protocol
|
||||
--disable_cursor_protocol
|
||||
--disable_view_protocol
|
||||
|
||||
# Passing NULL/nothing should return NULL
|
||||
SELECT sys.format_bytes(NULL);
|
||||
|
||||
|
|
|
@ -3538,7 +3538,7 @@ TEXT
|
|||
|
||||
##### Example
|
||||
```SQL
|
||||
mariadb> SELECT sys.format_bytes(2348723492723746) AS size;
|
||||
mariadb> SELECT format_bytes(2348723492723746) AS size;
|
||||
+----------+
|
||||
| size |
|
||||
+----------+
|
||||
|
@ -3546,7 +3546,7 @@ mariadb> SELECT sys.format_bytes(2348723492723746) AS size;
|
|||
+----------+
|
||||
1 row in set (0.00 sec)
|
||||
|
||||
mariadb> SELECT sys.format_bytes(2348723492723) AS size;
|
||||
mariadb> SELECT format_bytes(2348723492723) AS size;
|
||||
+----------+
|
||||
| size |
|
||||
+----------+
|
||||
|
@ -3554,7 +3554,7 @@ mariadb> SELECT sys.format_bytes(2348723492723) AS size;
|
|||
+----------+
|
||||
1 row in set (0.00 sec)
|
||||
|
||||
mariadb> SELECT sys.format_bytes(23487234) AS size;
|
||||
mariadb> SELECT format_bytes(23487234) AS size;
|
||||
+-----------+
|
||||
| size |
|
||||
+-----------+
|
||||
|
|
|
@ -353,12 +353,12 @@ BEGIN
|
|||
(''io_global_by_file_by_bytes'', ''total''),
|
||||
(''io_global_by_wait_by_bytes'', ''total_requested'')
|
||||
)
|
||||
THEN CONCAT(''sys.format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME)
|
||||
THEN CONCAT(''format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME)
|
||||
WHEN SUBSTRING(COLUMN_NAME, -8) = ''_latency''
|
||||
THEN CONCAT(''format_pico_time('', COLUMN_NAME, '') AS '', COLUMN_NAME)
|
||||
WHEN SUBSTRING(COLUMN_NAME, -7) = ''_memory'' OR SUBSTRING(COLUMN_NAME, -17) = ''_memory_allocated''
|
||||
OR ((SUBSTRING(COLUMN_NAME, -5) = ''_read'' OR SUBSTRING(COLUMN_NAME, -8) = ''_written'' OR SUBSTRING(COLUMN_NAME, -6) = ''_write'') AND SUBSTRING(COLUMN_NAME, 1, 6) <> ''COUNT_'')
|
||||
THEN CONCAT(''sys.format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME)
|
||||
THEN CONCAT(''format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME)
|
||||
ELSE COLUMN_NAME
|
||||
END
|
||||
ORDER BY ORDINAL_POSITION
|
||||
|
@ -383,7 +383,7 @@ BEGIN
|
|||
(''io_global_by_file_by_bytes'', ''total''),
|
||||
(''io_global_by_wait_by_bytes'', ''total_requested'')
|
||||
)
|
||||
THEN CONCAT(''sys.format_bytes(e.'', COLUMN_NAME, ''-IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME)
|
||||
THEN CONCAT(''format_bytes(e.'', COLUMN_NAME, ''-IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME)
|
||||
WHEN SUBSTRING(COLUMN_NAME, 1, 4) IN (''max_'', ''min_'') AND SUBSTRING(COLUMN_NAME, -8) = ''_latency''
|
||||
THEN CONCAT(''format_pico_time(e.'', COLUMN_NAME, '') AS '', COLUMN_NAME)
|
||||
WHEN COLUMN_NAME = ''avg_latency''
|
||||
|
@ -395,12 +395,12 @@ BEGIN
|
|||
WHEN SUBSTRING(COLUMN_NAME, -8) = ''_latency''
|
||||
THEN CONCAT(''format_pico_time(e.'', COLUMN_NAME, '' - IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME)
|
||||
WHEN COLUMN_NAME IN (''avg_read'', ''avg_write'', ''avg_written'')
|
||||
THEN CONCAT(''sys.format_bytes(IFNULL((e.total_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''written''), ''-IFNULL(s.total_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''written''), '', 0))'',
|
||||
THEN CONCAT(''format_bytes(IFNULL((e.total_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''written''), ''-IFNULL(s.total_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''written''), '', 0))'',
|
||||
''/NULLIF(e.count_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''write''), ''-IFNULL(s.count_'', IF(COLUMN_NAME = ''avg_read'', ''read'', ''write''), '', 0), 0), 0)) AS '',
|
||||
COLUMN_NAME)
|
||||
WHEN SUBSTRING(COLUMN_NAME, -7) = ''_memory'' OR SUBSTRING(COLUMN_NAME, -17) = ''_memory_allocated''
|
||||
OR ((SUBSTRING(COLUMN_NAME, -5) = ''_read'' OR SUBSTRING(COLUMN_NAME, -8) = ''_written'' OR SUBSTRING(COLUMN_NAME, -6) = ''_write'') AND SUBSTRING(COLUMN_NAME, 1, 6) <> ''COUNT_'')
|
||||
THEN CONCAT(''sys.format_bytes(e.'', COLUMN_NAME, '' - IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME)
|
||||
THEN CONCAT(''format_bytes(e.'', COLUMN_NAME, '' - IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME)
|
||||
ELSE CONCAT(''(e.'', COLUMN_NAME, '' - IFNULL(s.'', COLUMN_NAME, '', 0)) AS '', COLUMN_NAME)
|
||||
END
|
||||
ORDER BY ORDINAL_POSITION
|
||||
|
@ -785,7 +785,7 @@ SELECT ''UNIX_TIMESTAMP()'' AS Variable_name, ROUND(UNIX_TIMESTAMP(NOW(3)), 3) A
|
|||
EXECUTE stmt_ndbcluster_status;
|
||||
|
||||
SELECT 'ndbinfo.memoryusage' AS 'The following output is:';
|
||||
SELECT node_id, memory_type, sys.format_bytes(used) AS used, used_pages, sys.format_bytes(total) AS total, total_pages,
|
||||
SELECT node_id, memory_type, format_bytes(used) AS used, used_pages, format_bytes(total) AS total, total_pages,
|
||||
ROUND(100*(used/total), 2) AS 'Used %'
|
||||
FROM ndbinfo.memoryusage;
|
||||
|
||||
|
@ -870,9 +870,9 @@ SELECT ''UNIX_TIMESTAMP()'' AS Variable_name, ROUND(UNIX_TIMESTAMP(NOW(3)), 3) A
|
|||
IF (@sys.diagnostics.allow_i_s_tables = 'ON') THEN
|
||||
SELECT 'Storage Engine Usage' AS 'The following output is:';
|
||||
SELECT ENGINE, COUNT(*) AS NUM_TABLES,
|
||||
sys.format_bytes(SUM(DATA_LENGTH)) AS DATA_LENGTH,
|
||||
sys.format_bytes(SUM(INDEX_LENGTH)) AS INDEX_LENGTH,
|
||||
sys.format_bytes(SUM(DATA_LENGTH+INDEX_LENGTH)) AS TOTAL
|
||||
format_bytes(SUM(DATA_LENGTH)) AS DATA_LENGTH,
|
||||
format_bytes(SUM(INDEX_LENGTH)) AS INDEX_LENGTH,
|
||||
format_bytes(SUM(DATA_LENGTH+INDEX_LENGTH)) AS TOTAL
|
||||
FROM information_schema.TABLES
|
||||
GROUP BY ENGINE;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ SOURCE ./triggers/sys_config_update_set_user.sql
|
|||
|
||||
SOURCE ./functions/extract_schema_from_file_name.sql
|
||||
SOURCE ./functions/extract_table_from_file_name.sql
|
||||
SOURCE ./functions/format_bytes.sql
|
||||
SOURCE ./functions/format_path.sql
|
||||
SOURCE ./functions/format_statement.sql
|
||||
SOURCE ./functions/format_time.sql
|
||||
|
|
|
@ -25,7 +25,6 @@ SOURCE ./triggers/sys_config_update_set_user.sql
|
|||
|
||||
SOURCE ./functions/extract_schema_from_file_name.sql
|
||||
SOURCE ./functions/extract_table_from_file_name.sql
|
||||
SOURCE ./functions/format_bytes.sql
|
||||
SOURCE ./functions/format_path_57.sql
|
||||
SOURCE ./functions/format_statement.sql
|
||||
SOURCE ./functions/format_time.sql
|
||||
|
|
|
@ -50,8 +50,8 @@ VIEW innodb_buffer_stats_by_schema (
|
|||
rows_cached
|
||||
) AS
|
||||
SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', 1), '`', '')) AS object_schema,
|
||||
sys.format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
|
||||
sys.format_bytes(SUM(ibp.data_size)) AS data,
|
||||
format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
|
||||
format_bytes(SUM(ibp.data_size)) AS data,
|
||||
COUNT(ibp.page_number) AS pages,
|
||||
COUNT(IF(ibp.is_hashed = 'YES', 1, NULL)) AS pages_hashed,
|
||||
COUNT(IF(ibp.is_old = 'YES', 1, NULL)) AS pages_old,
|
||||
|
|
|
@ -53,8 +53,8 @@ VIEW innodb_buffer_stats_by_table (
|
|||
) AS
|
||||
SELECT IF(LOCATE('.', ibp.table_name) = 0, 'InnoDB System', REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', 1), '`', '')) AS object_schema,
|
||||
REPLACE(SUBSTRING_INDEX(ibp.table_name, '.', -1), '`', '') AS object_name,
|
||||
sys.format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
|
||||
sys.format_bytes(SUM(ibp.data_size)) AS data,
|
||||
format_bytes(SUM(IF(ibp.compressed_size = 0, 16384, compressed_size))) AS allocated,
|
||||
format_bytes(SUM(ibp.data_size)) AS data,
|
||||
COUNT(ibp.page_number) AS pages,
|
||||
COUNT(IF(ibp.is_hashed = 'YES', 1, NULL)) AS pages_hashed,
|
||||
COUNT(IF(ibp.is_old = 'YES', 1, NULL)) AS pages_old,
|
||||
|
|
|
@ -57,8 +57,8 @@ SELECT IF(accounts.host IS NULL, 'background', accounts.host) AS host,
|
|||
SUM(accounts.current_connections) AS current_connections,
|
||||
SUM(accounts.total_connections) AS total_connections,
|
||||
COUNT(DISTINCT user) AS unique_users,
|
||||
sys.format_bytes(SUM(mem.current_allocated)) AS current_memory,
|
||||
sys.format_bytes(SUM(mem.total_allocated)) AS total_memory_allocated
|
||||
format_bytes(SUM(mem.current_allocated)) AS current_memory,
|
||||
format_bytes(SUM(mem.total_allocated)) AS total_memory_allocated
|
||||
FROM performance_schema.accounts
|
||||
JOIN sys.x$host_summary_by_statement_latency AS stmt ON accounts.host = stmt.host
|
||||
JOIN sys.x$host_summary_by_file_io AS io ON accounts.host = io.host
|
||||
|
|
|
@ -47,12 +47,12 @@ VIEW io_global_by_file_by_bytes (
|
|||
) AS
|
||||
SELECT sys.format_path(file_name) AS file,
|
||||
count_read,
|
||||
sys.format_bytes(sum_number_of_bytes_read) AS total_read,
|
||||
sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
|
||||
format_bytes(sum_number_of_bytes_read) AS total_read,
|
||||
format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
|
||||
count_write,
|
||||
sys.format_bytes(sum_number_of_bytes_write) AS total_written,
|
||||
sys.format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0.00)) AS avg_write,
|
||||
sys.format_bytes(sum_number_of_bytes_read + sum_number_of_bytes_write) AS total,
|
||||
format_bytes(sum_number_of_bytes_write) AS total_written,
|
||||
format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0.00)) AS avg_write,
|
||||
format_bytes(sum_number_of_bytes_read + sum_number_of_bytes_write) AS total,
|
||||
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
|
||||
FROM performance_schema.file_summary_by_instance
|
||||
ORDER BY sum_number_of_bytes_read + sum_number_of_bytes_write DESC;
|
||||
|
|
|
@ -67,12 +67,12 @@ SELECT SUBSTRING_INDEX(event_name, '/', -2) event_name,
|
|||
format_pico_time(avg_timer_wait) AS avg_latency,
|
||||
format_pico_time(max_timer_wait) AS max_latency,
|
||||
count_read,
|
||||
sys.format_bytes(sum_number_of_bytes_read) AS total_read,
|
||||
sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
|
||||
format_bytes(sum_number_of_bytes_read) AS total_read,
|
||||
format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
|
||||
count_write,
|
||||
sys.format_bytes(sum_number_of_bytes_write) AS total_written,
|
||||
sys.format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0)) AS avg_written,
|
||||
sys.format_bytes(sum_number_of_bytes_write + sum_number_of_bytes_read) AS total_requested
|
||||
format_bytes(sum_number_of_bytes_write) AS total_written,
|
||||
format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0)) AS avg_written,
|
||||
format_bytes(sum_number_of_bytes_write + sum_number_of_bytes_read) AS total_requested
|
||||
FROM performance_schema.file_summary_by_event_name
|
||||
WHERE event_name LIKE 'wait/io/file/%'
|
||||
AND count_star > 0
|
||||
|
|
|
@ -70,11 +70,11 @@ SELECT SUBSTRING_INDEX(event_name, '/', -2) AS event_name,
|
|||
format_pico_time(sum_timer_write) AS write_latency,
|
||||
format_pico_time(sum_timer_misc) AS misc_latency,
|
||||
count_read,
|
||||
sys.format_bytes(sum_number_of_bytes_read) AS total_read,
|
||||
sys.format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
|
||||
format_bytes(sum_number_of_bytes_read) AS total_read,
|
||||
format_bytes(IFNULL(sum_number_of_bytes_read / NULLIF(count_read, 0), 0)) AS avg_read,
|
||||
count_write,
|
||||
sys.format_bytes(sum_number_of_bytes_write) AS total_written,
|
||||
sys.format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0)) AS avg_written
|
||||
format_bytes(sum_number_of_bytes_write) AS total_written,
|
||||
format_bytes(IFNULL(sum_number_of_bytes_write / NULLIF(count_write, 0), 0)) AS avg_written
|
||||
FROM performance_schema.file_summary_by_event_name
|
||||
WHERE event_name LIKE 'wait/io/file/%'
|
||||
AND count_star > 0
|
||||
|
|
|
@ -48,7 +48,7 @@ SELECT IF(id IS NULL,
|
|||
sys.format_path(object_name) file,
|
||||
format_pico_time(timer_wait) AS latency,
|
||||
operation,
|
||||
sys.format_bytes(number_of_bytes) AS requested
|
||||
format_bytes(number_of_bytes) AS requested
|
||||
FROM performance_schema.events_waits_history_long
|
||||
JOIN performance_schema.threads USING (thread_id)
|
||||
LEFT JOIN information_schema.processlist ON processlist_id = id
|
||||
|
|
|
@ -43,10 +43,10 @@ VIEW memory_by_host_by_current_bytes (
|
|||
) AS
|
||||
SELECT IF(host IS NULL, 'background', host) AS host,
|
||||
SUM(current_count_used) AS current_count_used,
|
||||
sys.format_bytes(SUM(current_number_of_bytes_used)) AS current_allocated,
|
||||
sys.format_bytes(IFNULL(SUM(current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
|
||||
sys.format_bytes(MAX(current_number_of_bytes_used)) AS current_max_alloc,
|
||||
sys.format_bytes(SUM(sum_number_of_bytes_alloc)) AS total_allocated
|
||||
format_bytes(SUM(current_number_of_bytes_used)) AS current_allocated,
|
||||
format_bytes(IFNULL(SUM(current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
|
||||
format_bytes(MAX(current_number_of_bytes_used)) AS current_max_alloc,
|
||||
format_bytes(SUM(sum_number_of_bytes_alloc)) AS total_allocated
|
||||
FROM performance_schema.memory_summary_by_host_by_event_name
|
||||
GROUP BY IF(host IS NULL, 'background', host)
|
||||
ORDER BY SUM(current_number_of_bytes_used) DESC;
|
||||
|
|
|
@ -50,10 +50,10 @@ SELECT thread_id,
|
|||
CONCAT(t.processlist_user, '@', t.processlist_host),
|
||||
REPLACE(t.name, 'thread/', '')) user,
|
||||
SUM(mt.current_count_used) AS current_count_used,
|
||||
sys.format_bytes(SUM(mt.current_number_of_bytes_used)) AS current_allocated,
|
||||
sys.format_bytes(IFNULL(SUM(mt.current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
|
||||
sys.format_bytes(MAX(mt.current_number_of_bytes_used)) AS current_max_alloc,
|
||||
sys.format_bytes(SUM(mt.sum_number_of_bytes_alloc)) AS total_allocated
|
||||
format_bytes(SUM(mt.current_number_of_bytes_used)) AS current_allocated,
|
||||
format_bytes(IFNULL(SUM(mt.current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
|
||||
format_bytes(MAX(mt.current_number_of_bytes_used)) AS current_max_alloc,
|
||||
format_bytes(SUM(mt.sum_number_of_bytes_alloc)) AS total_allocated
|
||||
FROM performance_schema.memory_summary_by_thread_by_event_name AS mt
|
||||
JOIN performance_schema.threads AS t USING (thread_id)
|
||||
GROUP BY thread_id, IF(t.name = 'thread/sql/one_connection',
|
||||
|
|
|
@ -43,10 +43,10 @@ VIEW memory_by_user_by_current_bytes (
|
|||
) AS
|
||||
SELECT IF(user IS NULL, 'background', user) AS user,
|
||||
SUM(current_count_used) AS current_count_used,
|
||||
sys.format_bytes(SUM(current_number_of_bytes_used)) AS current_allocated,
|
||||
sys.format_bytes(IFNULL(SUM(current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
|
||||
sys.format_bytes(MAX(current_number_of_bytes_used)) AS current_max_alloc,
|
||||
sys.format_bytes(SUM(sum_number_of_bytes_alloc)) AS total_allocated
|
||||
format_bytes(SUM(current_number_of_bytes_used)) AS current_allocated,
|
||||
format_bytes(IFNULL(SUM(current_number_of_bytes_used) / NULLIF(SUM(current_count_used), 0), 0)) AS current_avg_alloc,
|
||||
format_bytes(MAX(current_number_of_bytes_used)) AS current_max_alloc,
|
||||
format_bytes(SUM(sum_number_of_bytes_alloc)) AS total_allocated
|
||||
FROM performance_schema.memory_summary_by_user_by_event_name
|
||||
GROUP BY IF(user IS NULL, 'background', user)
|
||||
ORDER BY SUM(current_number_of_bytes_used) DESC;
|
||||
|
|
|
@ -46,11 +46,11 @@ VIEW memory_global_by_current_bytes (
|
|||
) AS
|
||||
SELECT event_name,
|
||||
current_count_used AS current_count,
|
||||
sys.format_bytes(current_number_of_bytes_used) AS current_alloc,
|
||||
sys.format_bytes(IFNULL(current_number_of_bytes_used / NULLIF(current_count_used, 0), 0)) AS current_avg_alloc,
|
||||
format_bytes(current_number_of_bytes_used) AS current_alloc,
|
||||
format_bytes(IFNULL(current_number_of_bytes_used / NULLIF(current_count_used, 0), 0)) AS current_avg_alloc,
|
||||
high_count_used AS high_count,
|
||||
sys.format_bytes(high_number_of_bytes_used) AS high_alloc,
|
||||
sys.format_bytes(IFNULL(high_number_of_bytes_used / NULLIF(high_count_used, 0), 0)) AS high_avg_alloc
|
||||
format_bytes(high_number_of_bytes_used) AS high_alloc,
|
||||
format_bytes(IFNULL(high_number_of_bytes_used / NULLIF(high_count_used, 0), 0)) AS high_avg_alloc
|
||||
FROM performance_schema.memory_summary_global_by_event_name
|
||||
WHERE current_number_of_bytes_used > 0
|
||||
ORDER BY current_number_of_bytes_used DESC;
|
||||
|
|
|
@ -33,5 +33,5 @@ CREATE OR REPLACE
|
|||
VIEW memory_global_total (
|
||||
total_allocated
|
||||
) AS
|
||||
SELECT sys.format_bytes(SUM(CURRENT_NUMBER_OF_BYTES_USED)) total_allocated
|
||||
SELECT format_bytes(SUM(CURRENT_NUMBER_OF_BYTES_USED)) total_allocated
|
||||
FROM performance_schema.memory_summary_global_by_event_name;
|
||||
|
|
|
@ -116,7 +116,7 @@ SELECT pps.thread_id AS thd_id,
|
|||
IF(esc.end_event_id IS NOT NULL,
|
||||
format_pico_time(esc.timer_wait),
|
||||
NULL) AS last_statement_latency,
|
||||
sys.format_bytes(mem.current_allocated) AS current_memory,
|
||||
format_bytes(mem.current_allocated) AS current_memory,
|
||||
ewc.event_name AS last_wait,
|
||||
IF(ewc.end_event_id IS NULL AND ewc.event_name IS NOT NULL,
|
||||
'Still Waiting',
|
||||
|
|
|
@ -80,10 +80,10 @@ SELECT pst.object_schema AS table_schema,
|
|||
pst.count_delete AS rows_deleted,
|
||||
format_pico_time(pst.sum_timer_delete) AS delete_latency,
|
||||
fsbi.count_read AS io_read_requests,
|
||||
sys.format_bytes(fsbi.sum_number_of_bytes_read) AS io_read,
|
||||
format_bytes(fsbi.sum_number_of_bytes_read) AS io_read,
|
||||
format_pico_time(fsbi.sum_timer_read) AS io_read_latency,
|
||||
fsbi.count_write AS io_write_requests,
|
||||
sys.format_bytes(fsbi.sum_number_of_bytes_write) AS io_write,
|
||||
format_bytes(fsbi.sum_number_of_bytes_write) AS io_write,
|
||||
format_pico_time(fsbi.sum_timer_write) AS io_write_latency,
|
||||
fsbi.count_misc AS io_misc_requests,
|
||||
format_pico_time(fsbi.sum_timer_misc) AS io_misc_latency
|
||||
|
|
|
@ -95,16 +95,16 @@ SELECT pst.object_schema AS table_schema,
|
|||
pst.count_delete AS rows_deleted,
|
||||
format_pico_time(pst.sum_timer_delete) AS delete_latency,
|
||||
fsbi.count_read AS io_read_requests,
|
||||
sys.format_bytes(fsbi.sum_number_of_bytes_read) AS io_read,
|
||||
format_bytes(fsbi.sum_number_of_bytes_read) AS io_read,
|
||||
format_pico_time(fsbi.sum_timer_read) AS io_read_latency,
|
||||
fsbi.count_write AS io_write_requests,
|
||||
sys.format_bytes(fsbi.sum_number_of_bytes_write) AS io_write,
|
||||
format_bytes(fsbi.sum_number_of_bytes_write) AS io_write,
|
||||
format_pico_time(fsbi.sum_timer_write) AS io_write_latency,
|
||||
fsbi.count_misc AS io_misc_requests,
|
||||
format_pico_time(fsbi.sum_timer_misc) AS io_misc_latency,
|
||||
sys.format_bytes(ibp.allocated) AS innodb_buffer_allocated,
|
||||
sys.format_bytes(ibp.data) AS innodb_buffer_data,
|
||||
sys.format_bytes(ibp.allocated - ibp.data) AS innodb_buffer_free,
|
||||
format_bytes(ibp.allocated) AS innodb_buffer_allocated,
|
||||
format_bytes(ibp.data) AS innodb_buffer_data,
|
||||
format_bytes(ibp.allocated - ibp.data) AS innodb_buffer_free,
|
||||
ibp.pages AS innodb_buffer_pages,
|
||||
ibp.pages_hashed AS innodb_buffer_pages_hashed,
|
||||
ibp.pages_old AS innodb_buffer_pages_old,
|
||||
|
|
|
@ -57,8 +57,8 @@ SELECT IF(accounts.user IS NULL, 'background', accounts.user) AS user,
|
|||
SUM(accounts.current_connections) AS current_connections,
|
||||
SUM(accounts.total_connections) AS total_connections,
|
||||
COUNT(DISTINCT host) AS unique_hosts,
|
||||
sys.format_bytes(SUM(mem.current_allocated)) AS current_memory,
|
||||
sys.format_bytes(SUM(mem.total_allocated)) AS total_memory_allocated
|
||||
format_bytes(SUM(mem.current_allocated)) AS current_memory,
|
||||
format_bytes(SUM(mem.total_allocated)) AS total_memory_allocated
|
||||
FROM performance_schema.accounts
|
||||
LEFT JOIN sys.x$user_summary_by_statement_latency AS stmt ON IF(accounts.user IS NULL, 'background', accounts.user) = stmt.user
|
||||
LEFT JOIN sys.x$user_summary_by_file_io AS io ON IF(accounts.user IS NULL, 'background', accounts.user) = io.user
|
||||
|
|
|
@ -867,15 +867,26 @@ protected:
|
|||
class Create_func_format_pico_time : public Create_func_arg1
|
||||
{
|
||||
public:
|
||||
Item *create_1_arg(THD *thd, Item *arg1) override;
|
||||
virtual Item *create_1_arg(THD *thd, Item *arg1) override;
|
||||
|
||||
static Create_func_format_pico_time s_singleton;
|
||||
static Create_func_format_pico_time s_singleton;
|
||||
|
||||
protected:
|
||||
Create_func_format_pico_time() = default;
|
||||
virtual ~Create_func_format_pico_time() = default;
|
||||
Create_func_format_pico_time() = default;
|
||||
virtual ~Create_func_format_pico_time() = default;
|
||||
};
|
||||
|
||||
class Create_func_format_bytes : public Create_func_arg1
|
||||
{
|
||||
public:
|
||||
virtual Item *create_1_arg(THD *thd, Item *arg1) override;
|
||||
|
||||
static Create_func_format_bytes s_singleton;
|
||||
|
||||
protected:
|
||||
Create_func_format_bytes() = default;
|
||||
virtual ~Create_func_format_bytes() = default;
|
||||
};
|
||||
|
||||
class Create_func_format : public Create_native_func
|
||||
{
|
||||
|
@ -4002,6 +4013,15 @@ Create_func_format_pico_time::create_1_arg(THD *thd, Item *arg1)
|
|||
}
|
||||
|
||||
|
||||
Create_func_format_bytes Create_func_format_bytes::s_singleton;
|
||||
|
||||
Item*
|
||||
Create_func_format_bytes::create_1_arg(THD *thd, Item *arg1)
|
||||
{
|
||||
return new (thd->mem_root) Item_func_format_bytes(thd, arg1);
|
||||
}
|
||||
|
||||
|
||||
Create_func_format Create_func_format::s_singleton;
|
||||
|
||||
Item*
|
||||
|
@ -6374,6 +6394,7 @@ const Native_func_registry func_array[] =
|
|||
{ { STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
|
||||
{ { STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
|
||||
{ { STRING_WITH_LEN("FORMAT_PICO_TIME") }, BUILDER(Create_func_format_pico_time)},
|
||||
{ { STRING_WITH_LEN("FORMAT_BYTES") }, BUILDER(Create_func_format_bytes)},
|
||||
{ { STRING_WITH_LEN("FORMAT") }, BUILDER(Create_func_format)},
|
||||
{ { STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
|
||||
{ { STRING_WITH_LEN("FROM_BASE64") }, BUILDER(Create_func_from_base64)},
|
||||
|
|
|
@ -6050,6 +6050,7 @@ bool Item_func_natural_sort_key::check_vcol_func_processor(void *arg)
|
|||
VCOL_NON_DETERMINISTIC);
|
||||
}
|
||||
|
||||
|
||||
String *Item_func_format_pico_time::val_str_ascii(String *)
|
||||
{
|
||||
double time_val= args[0]->val_real();
|
||||
|
@ -6128,6 +6129,78 @@ String *Item_func_format_pico_time::val_str_ascii(String *)
|
|||
return &m_value;
|
||||
}
|
||||
|
||||
|
||||
String *Item_func_format_bytes::val_str_ascii(String *)
|
||||
{
|
||||
double bytes= args[0]->val_real();
|
||||
|
||||
null_value = args[0]->null_value;
|
||||
if (null_value)
|
||||
return 0;
|
||||
|
||||
double bytes_abs= fabs(bytes);
|
||||
|
||||
constexpr uint64_t kib{1024};
|
||||
constexpr uint64_t mib{1024 * kib};
|
||||
constexpr uint64_t gib{1024 * mib};
|
||||
constexpr uint64_t tib{1024 * gib};
|
||||
constexpr uint64_t pib{1024 * tib};
|
||||
constexpr uint64_t eib{1024 * pib};
|
||||
|
||||
uint64_t divisor;
|
||||
size_t len;
|
||||
const char *unit;
|
||||
|
||||
if (bytes_abs >= eib)
|
||||
{
|
||||
divisor= eib;
|
||||
unit= "EiB";
|
||||
}
|
||||
else if (bytes_abs >= pib)
|
||||
{
|
||||
divisor= pib;
|
||||
unit= "PiB";
|
||||
}
|
||||
else if (bytes_abs >= tib)
|
||||
{
|
||||
divisor= tib;
|
||||
unit= "TiB";
|
||||
}
|
||||
else if (bytes_abs >= gib)
|
||||
{
|
||||
divisor= gib;
|
||||
unit= "GiB";
|
||||
}
|
||||
else if (bytes_abs >= mib)
|
||||
{
|
||||
divisor= mib;
|
||||
unit= "MiB";
|
||||
}
|
||||
else if (bytes_abs >= kib)
|
||||
{
|
||||
divisor= kib;
|
||||
unit= "KiB";
|
||||
}
|
||||
else
|
||||
{
|
||||
divisor= 1;
|
||||
unit= "bytes";
|
||||
}
|
||||
|
||||
if (divisor == 1)
|
||||
len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%4d %s", (int)bytes, unit);
|
||||
else
|
||||
{
|
||||
double value= bytes / divisor;
|
||||
if (fabs(value) >= 100000.0)
|
||||
len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%4.2e %s", value, unit);
|
||||
else
|
||||
len= snprintf(m_value_buffer, sizeof(m_value_buffer), "%4.2f %s", value, unit);
|
||||
}
|
||||
m_value.length(len);
|
||||
return &m_value;
|
||||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
#include "wsrep_mysqld.h"
|
||||
#include "wsrep_server_state.h"
|
||||
|
|
|
@ -2408,6 +2408,7 @@ public:
|
|||
{ return get_item_copy<Item_temptable_rowid>(thd, this); }
|
||||
};
|
||||
|
||||
|
||||
class Item_func_format_pico_time : public Item_str_ascii_func
|
||||
{
|
||||
/* Format is 'AAAA.BB UUU' = 11 characters or 'AAA ps' = 6 characters. */
|
||||
|
@ -2434,6 +2435,33 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class Item_func_format_bytes : public Item_str_ascii_func
|
||||
{
|
||||
/* Format is '-A.AAe+BB UUU' = 13 or 'AAAA.BB UUU' = 11 characters or 'AAAA bytes' = 10 characters. */
|
||||
char m_value_buffer[14];
|
||||
String m_value;
|
||||
|
||||
public:
|
||||
Item_func_format_bytes(THD *thd, Item *a): Item_str_ascii_func(thd, a) {}
|
||||
String *val_str_ascii(String *) override;
|
||||
LEX_CSTRING func_name_cstring() const override
|
||||
{
|
||||
static LEX_CSTRING name= {STRING_WITH_LEN("format_bytes")};
|
||||
return name;
|
||||
}
|
||||
bool fix_length_and_dec(THD *thd) override
|
||||
{
|
||||
m_value.set(m_value_buffer, sizeof(m_value_buffer), default_charset());
|
||||
fix_length_and_charset(sizeof(m_value_buffer), default_charset());
|
||||
return false;
|
||||
}
|
||||
Item *do_get_copy(THD *thd) const override
|
||||
{
|
||||
return get_item_copy<Item_func_format_bytes>(thd, this);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
|
||||
#include "wsrep_api.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue