1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
DROP TABLE IF EXISTS t1;
select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key;
show columns from information_schema.client_statistics;
Field Type Null Key Default Extra
CLIENT varchar(64) NO
TOTAL_CONNECTIONS bigint(21) NO 0
CONCURRENT_CONNECTIONS bigint(21) NO 0
CONNECTED_TIME bigint(21) NO 0
BUSY_TIME double NO 0
CPU_TIME double NO 0
BYTES_RECEIVED bigint(21) NO 0
BYTES_SENT bigint(21) NO 0
BINLOG_BYTES_WRITTEN bigint(21) NO 0
ROWS_READ bigint(21) NO 0
ROWS_SENT bigint(21) NO 0
ROWS_DELETED bigint(21) NO 0
ROWS_INSERTED bigint(21) NO 0
ROWS_UPDATED bigint(21) NO 0
SELECT_COMMANDS bigint(21) NO 0
UPDATE_COMMANDS bigint(21) NO 0
OTHER_COMMANDS bigint(21) NO 0
COMMIT_TRANSACTIONS bigint(21) NO 0
ROLLBACK_TRANSACTIONS bigint(21) NO 0
DENIED_CONNECTIONS bigint(21) NO 0
LOST_CONNECTIONS bigint(21) NO 0
ACCESS_DENIED bigint(21) NO 0
EMPTY_QUERIES bigint(21) NO 0
show columns from information_schema.user_statistics;
Field Type Null Key Default Extra
USER varchar(48) NO
TOTAL_CONNECTIONS int(11) NO 0
CONCURRENT_CONNECTIONS int(11) NO 0
CONNECTED_TIME int(11) NO 0
BUSY_TIME double NO 0
CPU_TIME double NO 0
BYTES_RECEIVED bigint(21) NO 0
BYTES_SENT bigint(21) NO 0
BINLOG_BYTES_WRITTEN bigint(21) NO 0
ROWS_READ bigint(21) NO 0
ROWS_SENT bigint(21) NO 0
ROWS_DELETED bigint(21) NO 0
ROWS_INSERTED bigint(21) NO 0
ROWS_UPDATED bigint(21) NO 0
SELECT_COMMANDS bigint(21) NO 0
UPDATE_COMMANDS bigint(21) NO 0
OTHER_COMMANDS bigint(21) NO 0
COMMIT_TRANSACTIONS bigint(21) NO 0
ROLLBACK_TRANSACTIONS bigint(21) NO 0
DENIED_CONNECTIONS bigint(21) NO 0
LOST_CONNECTIONS bigint(21) NO 0
ACCESS_DENIED bigint(21) NO 0
EMPTY_QUERIES bigint(21) NO 0
show columns from information_schema.index_statistics;
Field Type Null Key Default Extra
TABLE_SCHEMA varchar(192) NO
TABLE_NAME varchar(192) NO
INDEX_NAME varchar(192) NO
ROWS_READ bigint(21) NO 0
show columns from information_schema.table_statistics;
Field Type Null Key Default Extra
TABLE_SCHEMA varchar(192) NO
TABLE_NAME varchar(192) NO
ROWS_READ bigint(21) NO 0
ROWS_CHANGED bigint(21) NO 0
ROWS_CHANGED_X_INDEXES bigint(21) NO 0
set @save_general_log=@@global.general_log;
set @@global.general_log=0;
set @@global.userstat=1;
flush status;
create table t1 (a int, primary key (a), b int default 0) engine=innodb;
insert into t1 (a) values (1),(2),(3),(4);
update t1 set b=1;
update t1 set b=5 where a=2;
delete from t1 where a=3;
/* Empty query */
select * from t1 where a=999;
a b
drop table t1;
create table t1 (a int, primary key (a), b int default 0) engine=innodb;
begin;
insert into t1 values(1,1);
commit;
begin;
insert into t1 values(2,2);
commit;
begin;
insert into t1 values(3,3);
rollback;
drop table t1;
select sleep(1);
sleep(1)
0
show status like "rows%";
Variable_name Value
Rows_read 6
Rows_sent 1
show status like "ha%";
Variable_name Value
Handler_commit 19
Handler_delete 1
Handler_discover 0
Handler_prepare 18
Handler_read_first 0
Handler_read_key 3
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 5
Handler_rollback 2
Handler_savepoint 0
Handler_savepoint_rollback 0
Handler_update 5
Handler_write 7
select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key";
handler_read_key
3
set @@global.userstat=0;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
test t1 PRIMARY 2
select * from information_schema.table_statistics;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
test t1 6 13 13
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
test t1 6 13 13
show index_statistics;
Table_schema Table_name Index_name Rows_read
test t1 PRIMARY 2
select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;;
TOTAL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0
ROWS_READ 6
ROWS_SENT 2
ROWS_DELETED 1
ROWS_INSERTED 8
ROWS_UPDATED 5
SELECT_COMMANDS 3
UPDATE_COMMANDS 11
OTHER_COMMANDS 7
COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0
ACCESS_DENIED 0
EMPTY_QUERIES 1
select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;;
TOTAL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0
ROWS_READ 6
ROWS_SENT 2
ROWS_DELETED 1
ROWS_INSERTED 8
ROWS_UPDATED 5
SELECT_COMMANDS 3
UPDATE_COMMANDS 11
OTHER_COMMANDS 7
COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0
ACCESS_DENIED 0
EMPTY_QUERIES 1
flush table_statistics;
flush index_statistics;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
select * from information_schema.table_statistics;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
show status like "%statistics%";
Variable_name Value
Com_show_client_statistics 0
Com_show_index_statistics 1
Com_show_table_statistics 1
Com_show_user_statistics 0
select connected_time <> 0, busy_time <> 0, bytes_received <> 0,
bytes_sent <> 0, binlog_bytes_written <> 0
from information_schema.user_statistics;
connected_time <> 0 busy_time <> 0 bytes_received <> 0 bytes_sent <> 0 binlog_bytes_written <> 0
1 1 1 1 1
select connected_time <> 0, busy_time <> 0, bytes_received <> 0,
bytes_sent <> 0, binlog_bytes_written <> 0
from information_schema.client_statistics;
connected_time <> 0 busy_time <> 0 bytes_received <> 0 bytes_sent <> 0 binlog_bytes_written <> 0
1 1 1 1 1
set @@global.general_log=@save_general_log;
|