2
show status like 'Table_lock%';
4
Table_locks_immediate 1
6
select * from information_schema.session_status where variable_name like 'Table_lock%';
7
VARIABLE_NAME VARIABLE_VALUE
8
TABLE_LOCKS_IMMEDIATE 2
11
set @old_general_log = @@global.general_log;
12
set global general_log = 'OFF';
13
drop table if exists t1;
14
create table t1(n int) engine=myisam;
15
insert into t1 values(1);
21
show status like 'Table_locks_waited';
25
set global general_log = @old_general_log;
29
show status like 'last_query_cost';
31
Last_query_cost 0.000000
32
create table t1 (a int);
33
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
34
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
35
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
36
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
37
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
38
select * from t1 where a=6;
45
show status like 'last_query_cost';
47
Last_query_cost 12.084449
48
show status like 'last_query_cost';
50
Last_query_cost 12.084449
54
show status like 'last_query_cost';
56
Last_query_cost 0.000000
59
SHOW STATUS LIKE 'max_used_connections';
61
Max_used_connections 1
62
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
63
VARIABLE_NAME VARIABLE_VALUE
64
MAX_USED_CONNECTIONS 1
65
SET @save_thread_cache_size=@@thread_cache_size;
66
SET GLOBAL thread_cache_size=3;
67
SHOW STATUS LIKE 'max_used_connections';
69
Max_used_connections 3
70
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
71
VARIABLE_NAME VARIABLE_VALUE
72
MAX_USED_CONNECTIONS 3
74
SHOW STATUS LIKE 'max_used_connections';
76
Max_used_connections 2
77
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
78
VARIABLE_NAME VARIABLE_VALUE
79
MAX_USED_CONNECTIONS 2
80
SHOW STATUS LIKE 'max_used_connections';
82
Max_used_connections 3
83
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
84
VARIABLE_NAME VARIABLE_VALUE
85
MAX_USED_CONNECTIONS 3
86
SHOW STATUS LIKE 'max_used_connections';
88
Max_used_connections 4
89
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
90
VARIABLE_NAME VARIABLE_VALUE
91
MAX_USED_CONNECTIONS 4
92
SET GLOBAL thread_cache_size=@save_thread_cache_size;
93
CREATE TABLE t1 ( a INT );
94
INSERT INTO t1 VALUES (1), (2);
95
SELECT a FROM t1 LIMIT 1;
98
SHOW SESSION STATUS LIKE 'Last_query_cost';
100
Last_query_cost 2.402418
101
EXPLAIN SELECT a FROM t1;
102
id select_type table type possible_keys key key_len ref rows Extra
103
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
104
SHOW SESSION STATUS LIKE 'Last_query_cost';
106
Last_query_cost 2.402418
107
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
111
SHOW SESSION STATUS LIKE 'Last_query_cost';
113
Last_query_cost 0.000000
114
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
115
id select_type table type possible_keys key key_len ref rows Extra
116
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
117
2 UNION t1 ALL NULL NULL NULL NULL 2
118
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL Using filesort
119
SHOW SESSION STATUS LIKE 'Last_query_cost';
121
Last_query_cost 0.000000
122
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
123
a IN (SELECT a FROM t1)
125
SHOW SESSION STATUS LIKE 'Last_query_cost';
127
Last_query_cost 0.000000
128
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
131
SHOW SESSION STATUS LIKE 'Last_query_cost';
133
Last_query_cost 0.000000
134
SELECT * FROM t1 a, t1 b LIMIT 1;
137
SHOW SESSION STATUS LIKE 'Last_query_cost';
139
Last_query_cost 4.805836
141
show status like 'com_show_status';
144
show status like 'hand%write%';
147
show status like '%tmp%';
149
Created_tmp_disk_tables 0
152
show status like 'hand%write%';
155
show status like '%tmp%';
157
Created_tmp_disk_tables 0
160
show status like 'com_show_status';
163
rnd_diff tmp_table_diff
165
show global status like 'Com%function%';
168
Com_create_function 0
170
Com_show_function_code 0
171
Com_show_function_status 0
172
create function f1 (x INTEGER) returns integer
179
show global status like 'Com%function%';
182
Com_create_function 1
184
Com_show_function_code 0
185
Com_show_function_status 0
186
SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
187
SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
189
SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
191
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
192
VARIABLE_NAME VARIABLE_VALUE
193
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;
194
VARIABLE_NAME VARIABLE_VALUE