| 1 |
show databases; |
| 2 |
Database |
| 3 |
information_schema |
| 4 |
mtr |
| 5 |
mysql |
| 6 |
performance_schema |
| 7 |
sys |
| 8 |
test |
| 9 |
select count(*) from performance_schema.performance_timers; |
| 10 |
count(*) |
| 11 |
5 |
| 12 |
select count(*) from performance_schema.setup_consumers; |
| 13 |
count(*) |
| 14 |
16 |
| 15 |
select count(*) > 4 from performance_schema.setup_instruments; |
| 16 |
count(*) > 4 |
| 17 |
1 |
| 18 |
select * from performance_schema.accounts; |
| 19 |
select * from performance_schema.cond_instances; |
| 20 |
select * from performance_schema.events_stages_current; |
| 21 |
select * from performance_schema.events_stages_history; |
| 22 |
select * from performance_schema.events_stages_history_long; |
| 23 |
select * from performance_schema.events_stages_summary_by_account_by_event_name; |
| 24 |
select * from performance_schema.events_stages_summary_by_host_by_event_name; |
| 25 |
select * from performance_schema.events_stages_summary_by_thread_by_event_name; |
| 26 |
select * from performance_schema.events_stages_summary_by_user_by_event_name; |
| 27 |
select * from performance_schema.events_stages_summary_global_by_event_name; |
| 28 |
select * from performance_schema.events_statements_current; |
| 29 |
select * from performance_schema.events_statements_histogram_by_digest; |
| 30 |
select * from performance_schema.events_statements_histogram_global; |
| 31 |
select * from performance_schema.events_statements_history; |
| 32 |
select * from performance_schema.events_statements_history_long; |
| 33 |
select * from performance_schema.events_statements_summary_by_account_by_event_name; |
| 34 |
select * from performance_schema.events_statements_summary_by_digest; |
| 35 |
select * from performance_schema.events_statements_summary_by_host_by_event_name; |
| 36 |
select * from performance_schema.events_statements_summary_by_thread_by_event_name; |
| 37 |
select * from performance_schema.events_statements_summary_by_user_by_event_name; |
| 38 |
select * from performance_schema.events_statements_summary_global_by_event_name; |
| 39 |
select * from performance_schema.events_transactions_current; |
| 40 |
select * from performance_schema.events_transactions_history; |
| 41 |
select * from performance_schema.events_transactions_history_long; |
| 42 |
select * from performance_schema.events_transactions_summary_by_account_by_event_name; |
| 43 |
select * from performance_schema.events_transactions_summary_by_host_by_event_name; |
| 44 |
select * from performance_schema.events_transactions_summary_by_thread_by_event_name; |
| 45 |
select * from performance_schema.events_transactions_summary_by_user_by_event_name; |
| 46 |
select * from performance_schema.events_transactions_summary_global_by_event_name; |
| 47 |
select * from performance_schema.events_waits_current; |
| 48 |
select * from performance_schema.events_waits_history; |
| 49 |
select * from performance_schema.events_waits_history_long; |
| 50 |
select * from performance_schema.events_waits_summary_by_account_by_event_name; |
| 51 |
select * from performance_schema.events_waits_summary_by_host_by_event_name; |
| 52 |
select * from performance_schema.events_waits_summary_by_instance; |
| 53 |
select * from performance_schema.events_waits_summary_by_thread_by_event_name; |
| 54 |
select * from performance_schema.events_waits_summary_by_user_by_event_name; |
| 55 |
select * from performance_schema.events_waits_summary_global_by_event_name; |
| 56 |
select * from performance_schema.memory_summary_by_account_by_event_name; |
| 57 |
select * from performance_schema.memory_summary_by_host_by_event_name; |
| 58 |
select * from performance_schema.memory_summary_by_thread_by_event_name; |
| 59 |
select * from performance_schema.memory_summary_by_user_by_event_name; |
| 60 |
select * from performance_schema.memory_summary_global_by_event_name; |
| 61 |
select * from performance_schema.events_errors_summary_by_account_by_error; |
| 62 |
select * from performance_schema.events_errors_summary_by_host_by_error; |
| 63 |
select * from performance_schema.events_errors_summary_by_thread_by_error; |
| 64 |
select * from performance_schema.events_errors_summary_by_user_by_error; |
| 65 |
select * from performance_schema.events_errors_summary_global_by_error; |
| 66 |
select * from performance_schema.file_instances; |
| 67 |
select * from performance_schema.file_summary_by_event_name; |
| 68 |
select * from performance_schema.file_summary_by_instance; |
| 69 |
select * from performance_schema.host_cache; |
| 70 |
select * from performance_schema.hosts; |
| 71 |
select * from performance_schema.memory_summary_by_account_by_event_name; |
| 72 |
select * from performance_schema.memory_summary_by_host_by_event_name; |
| 73 |
select * from performance_schema.memory_summary_by_thread_by_event_name; |
| 74 |
select * from performance_schema.memory_summary_by_user_by_event_name; |
| 75 |
select * from performance_schema.memory_summary_global_by_event_name; |
| 76 |
select * from performance_schema.metadata_locks; |
| 77 |
select * from performance_schema.mutex_instances; |
| 78 |
select * from performance_schema.objects_summary_global_by_type; |
| 79 |
select * from performance_schema.performance_timers; |
| 80 |
select * from performance_schema.rwlock_instances; |
| 81 |
select * from performance_schema.data_locks; |
| 82 |
select * from performance_schema.data_lock_waits; |
| 83 |
select * from performance_schema.session_account_connect_attrs; |
| 84 |
select * from performance_schema.session_connect_attrs; |
| 85 |
select * from performance_schema.setup_actors; |
| 86 |
select * from performance_schema.setup_consumers; |
| 87 |
select * from performance_schema.setup_instruments; |
| 88 |
select * from performance_schema.setup_objects; |
| 89 |
select * from performance_schema.setup_threads; |
| 90 |
select * from performance_schema.socket_instances; |
| 91 |
select * from performance_schema.socket_summary_by_instance; |
| 92 |
select * from performance_schema.socket_summary_by_event_name; |
| 93 |
select * from performance_schema.table_handles; |
| 94 |
select * from performance_schema.table_io_waits_summary_by_index_usage; |
| 95 |
select * from performance_schema.table_io_waits_summary_by_table; |
| 96 |
select * from performance_schema.table_lock_waits_summary_by_table; |
| 97 |
select * from performance_schema.threads; |
| 98 |
select * from performance_schema.users; |
| 99 |
select * from performance_schema.replication_connection_configuration; |
| 100 |
select * from performance_schema.replication_connection_status; |
| 101 |
select * from performance_schema.replication_applier_configuration; |
| 102 |
select * from performance_schema.replication_applier_status; |
| 103 |
select * from performance_schema.replication_applier_status_by_coordinator; |
| 104 |
select * from performance_schema.replication_applier_status_by_worker; |
| 105 |
select * from performance_schema.global_status; |
| 106 |
select * from performance_schema.status_by_thread; |
| 107 |
select * from performance_schema.status_by_user; |
| 108 |
select * from performance_schema.status_by_host; |
| 109 |
select * from performance_schema.status_by_account; |
| 110 |
select * from performance_schema.session_status; |
| 111 |
select * from performance_schema.global_variables; |
| 112 |
select * from performance_schema.variables_by_thread; |
| 113 |
select * from performance_schema.session_variables; |
| 114 |
show engine PERFORMANCE_SCHEMA status; |
| 115 |
show global status like "performance_schema%"; |
| 116 |
show global variables like "performance_schema_max_program_instances"; |
| 117 |
Variable_name Value |
| 118 |
performance_schema_max_program_instances 0 |
| 119 |
show global variables like "performance_schema_max_statement_stack"; |
| 120 |
Variable_name Value |
| 121 |
performance_schema_max_statement_stack 1 |
| 122 |
##################### |
| 123 |
# Setup |
| 124 |
##################### |
| 125 |
# SET-UP |
| 126 |
CREATE DATABASE nested_sp; |
| 127 |
USE nested_sp; |
| 128 |
CREATE TABLE t1( |
| 129 |
id CHAR(16) NOT NULL DEFAULT '', |
| 130 |
data INT NOT NULL |
| 131 |
); |
| 132 |
CREATE TABLE t2( |
| 133 |
n INT UNSIGNED NOT NULL, |
| 134 |
f BIGINT UNSIGNED |
| 135 |
); |
| 136 |
############################ |
| 137 |
# Creating Stored Programs # |
| 138 |
############################ |
| 139 |
CREATE PROCEDURE c1(x INT) |
| 140 |
CALL c2("c", x)| |
| 141 |
CREATE PROCEDURE c2(s CHAR(16), x INT) |
| 142 |
CALL c3(x, s)| |
| 143 |
CREATE PROCEDURE c3(x INT, s CHAR(16)) |
| 144 |
CALL c4("level", x, s)| |
| 145 |
CREATE PROCEDURE c4(l CHAR(8), x INT, s CHAR(16)) |
| 146 |
INSERT INTO t1 VALUES (concat(l,s), x)| |
| 147 |
CREATE PROCEDURE iotest(x1 CHAR(16), x2 CHAR(16), y INT) |
| 148 |
BEGIN |
| 149 |
CALL inc2(x2, y); |
| 150 |
INSERT INTO t1 VALUES (x1, y); |
| 151 |
END| |
| 152 |
CREATE PROCEDURE inc2(x CHAR(16), y INT) |
| 153 |
BEGIN |
| 154 |
CALL inc(y); |
| 155 |
INSERT INTO t1 VALUES (x, y); |
| 156 |
END| |
| 157 |
CREATE PROCEDURE inc(inout io INT) |
| 158 |
SET io = io + 1| |
| 159 |
CREATE FUNCTION mul(x INT, y INT) RETURNS INT |
| 160 |
RETURN x*y| |
| 161 |
CREATE FUNCTION inc(i INT) RETURNS INT |
| 162 |
RETURN i+1| |
| 163 |
CREATE FUNCTION fac(n INT UNSIGNED) RETURNS BIGINT UNSIGNED |
| 164 |
BEGIN |
| 165 |
DECLARE f BIGINT UNSIGNED DEFAULT 1; |
| 166 |
WHILE n > 1 DO |
| 167 |
SET f = f * n; |
| 168 |
SET n = n - 1; |
| 169 |
END WHILE; |
| 170 |
RETURN f; |
| 171 |
END| |
| 172 |
CREATE FUNCTION fun(i INT, u INT UNSIGNED) RETURNS DOUBLE |
| 173 |
RETURN mul(inc(i), fac(u))| |
| 174 |
CREATE PROCEDURE ifac(n INT UNSIGNED) |
| 175 |
BEGIN |
| 176 |
DECLARE i BIGINT UNSIGNED DEFAULT 1; |
| 177 |
IF n > 20 THEN |
| 178 |
SET n = 20; # bigint overflow otherwise |
| 179 |
END IF; |
| 180 |
WHILE i <= n DO |
| 181 |
BEGIN |
| 182 |
INSERT INTO t2 VALUES (i, fac(i)); |
| 183 |
SET i = i + 1; |
| 184 |
END; |
| 185 |
END WHILE; |
| 186 |
END| |
| 187 |
CREATE TRIGGER trg AFTER INSERT ON t1 FOR EACH ROW |
| 188 |
CALL ifac(10)| |
| 189 |
TRUNCATE performance_schema.events_statements_summary_by_program; |
| 190 |
##################### |
| 191 |
# Executing Queries |
| 192 |
##################### |
| 193 |
##################### |
| 194 |
# Executing queries # |
| 195 |
##################### |
| 196 |
CALL c1(42); |
| 197 |
SELECT * FROM t1; |
| 198 |
id data |
| 199 |
levelc 42 |
| 200 |
DELETE FROM t1; |
| 201 |
CALL iotest("io1", "io2", 1); |
| 202 |
SELECT * FROM t1 ORDER BY data DESC; |
| 203 |
id data |
| 204 |
io2 2 |
| 205 |
io1 1 |
| 206 |
DELETE FROM t1; |
| 207 |
SELECT fun(6,10); |
| 208 |
fun(6,10) |
| 209 |
25401600 |
| 210 |
INSERT INTO t1 VALUES (20,13); |
| 211 |
SELECT * FROM t2; |
| 212 |
n f |
| 213 |
1 1 |
| 214 |
2 2 |
| 215 |
3 6 |
| 216 |
4 24 |
| 217 |
5 120 |
| 218 |
6 720 |
| 219 |
7 5040 |
| 220 |
8 40320 |
| 221 |
9 362880 |
| 222 |
10 3628800 |
| 223 |
1 1 |
| 224 |
2 2 |
| 225 |
3 6 |
| 226 |
4 24 |
| 227 |
5 120 |
| 228 |
6 720 |
| 229 |
7 5040 |
| 230 |
8 40320 |
| 231 |
9 362880 |
| 232 |
10 3628800 |
| 233 |
1 1 |
| 234 |
2 2 |
| 235 |
3 6 |
| 236 |
4 24 |
| 237 |
5 120 |
| 238 |
6 720 |
| 239 |
7 5040 |
| 240 |
8 40320 |
| 241 |
9 362880 |
| 242 |
10 3628800 |
| 243 |
1 1 |
| 244 |
2 2 |
| 245 |
3 6 |
| 246 |
4 24 |
| 247 |
5 120 |
| 248 |
6 720 |
| 249 |
7 5040 |
| 250 |
8 40320 |
| 251 |
9 362880 |
| 252 |
10 3628800 |
| 253 |
########################################### |
| 254 |
# Quering PS statement summary table # |
| 255 |
########################################### |
| 256 |
SELECT OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA |
| 257 |
FROM performance_schema.events_statements_summary_by_program; |
| 258 |
OBJECT_TYPE OBJECT_NAME OBJECT_SCHEMA |
| 259 |
SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_program; |
| 260 |
COUNT(*) |
| 261 |
0 |
| 262 |
##################### |
| 263 |
# Cleanup |
| 264 |
##################### |
| 265 |
DROP PROCEDURE c4; |
| 266 |
DROP PROCEDURE c3; |
| 267 |
DROP PROCEDURE c2; |
| 268 |
DROP PROCEDURE c1; |
| 269 |
DROP PROCEDURE inc; |
| 270 |
DROP PROCEDURE inc2; |
| 271 |
DROP PROCEDURE iotest; |
| 272 |
DROP FUNCTION mul; |
| 273 |
DROP FUNCTION inc; |
| 274 |
DROP FUNCTION fac; |
| 275 |
DROP FUNCTION fun; |
| 276 |
DROP PROCEDURE ifac; |
| 277 |
DROP TRIGGER trg; |
| 278 |
DROP TABLE t1,t2; |
| 279 |
DROP DATABASE nested_sp; |