Skip to content

Commit ecc7961

Browse files
committed
MDEV-34571 Add page accessed and pages read from disk to table_stats
Trivial batch, using the handler statistics already collected for the slow query log. The reason for the changes in test cases was mainly to change to use select TABLE_SCHEMA ... from information_schema.table_statistics instead of 'show table_statistics' to avoid future changes to test results if we add more columns to table_statistics.
1 parent d1af7fd commit ecc7961

17 files changed

+62
-41
lines changed

mysql-test/main/information_schema_stats.result

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
2020
test just_a_test IND_just_a_test_first_name_last_name 1 1
2121
test just_a_test IND_just_a_test_state 2 1
2222
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
23-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
24-
test just_a_test 18 5 5 5 0 0 2 0
23+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
24+
test just_a_test 18 5 5 5 0 0 2 0 0 0
2525
alter table just_a_test drop key IND_just_a_test_first_name_last_name;
2626
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
2727
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
2828
test just_a_test IND_just_a_test_state 2 1
2929
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
30-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
31-
test just_a_test 23 5 5 5 0 0 2 0
30+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
31+
test just_a_test 23 5 5 5 0 0 2 0 0 0
3232
alter table just_a_test drop column state;
3333
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
3434
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
@@ -40,18 +40,18 @@ select * from just_a_test force index(primary) where id=8;
4040
id first_name last_name address phone email
4141
update just_a_test set first_name="unlucky" where id=5;
4242
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
43-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
44-
test just_a_test 31 6 6 5 1 0 4 1
43+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
44+
test just_a_test 31 6 6 5 1 0 4 1 0 0
4545
delete from just_a_test where id=5;
4646
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
47-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
48-
test just_a_test 32 7 7 5 1 1 5 1
47+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
48+
test just_a_test 32 7 7 5 1 1 5 1 0 0
4949
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
5050
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
5151
test just_a_test PRIMARY 4 3
5252
drop table just_a_test;
5353
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
54-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
54+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
5555
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
5656
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
5757
create table just_a_test(id int not null primary key,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30),key(first_name,last_name),key(state));
@@ -75,12 +75,12 @@ test just_a_test PRIMARY 4 1
7575
test just_a_test first_name 1 1
7676
test just_a_test state 2 1
7777
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
78-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
79-
test just_a_test 7 5 15 5 0 0 3 0
78+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
79+
test just_a_test 7 5 15 5 0 0 3 0 0 0
8080
drop table just_a_test;
8181
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
8282
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
8383
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
84-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
84+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
8585
set global userstat=@save_userstat;
8686
# End of 11.5 tests

mysql-test/main/lowercase_table5.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ a
129129
3
130130
4
131131
SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS ORDER BY BINARY TABLE_NAME;
132-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
133-
test T1 4 4 4 4 0 0 0 0
134-
test t1 4 4 4 4 0 0 0 0
132+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
133+
test T1 4 4 4 4 0 0 0 0 0 0
134+
test t1 4 4 4 4 0 0 0 0 0 0
135135
SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS ORDER BY BINARY TABLE_NAME;
136136
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
137137
test T1 a 4 1

mysql-test/main/subselect.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7125,8 +7125,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
71257125
MIN(b)
71267126
NULL
71277127
# The following shows that t2 was indeed scanned with a full scan.
7128-
show table_statistics;
7129-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
7128+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
7129+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
71307130
test t1 2 0 0 0 0 0 0 0
71317131
test t2 3 0 0 0 0 0 1 0
71327132
test t3 0 0 0 0 0 0 0 1

mysql-test/main/subselect.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5954,8 +5954,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
59545954
--enable_ps2_protocol
59555955

59565956
--echo # The following shows that t2 was indeed scanned with a full scan.
5957-
--sorted_result
5958-
show table_statistics;
5957+
--sorted_result
5958+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
59595959
show index_statistics;
59605960
set global userstat=@tmp_mdev410;
59615961

mysql-test/main/subselect_no_exists_to_in.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7127,8 +7127,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
71277127
MIN(b)
71287128
NULL
71297129
# The following shows that t2 was indeed scanned with a full scan.
7130-
show table_statistics;
7131-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
7130+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
7131+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
71327132
test t1 2 0 0 0 0 0 0 0
71337133
test t2 3 0 0 0 0 0 1 0
71347134
test t3 0 0 0 0 0 0 0 1

mysql-test/main/subselect_no_mat.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7123,8 +7123,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
71237123
MIN(b)
71247124
NULL
71257125
# The following shows that t2 was indeed scanned with a full scan.
7126-
show table_statistics;
7127-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
7126+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
7127+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
71287128
test t1 2 0 0 0 0 0 0 0
71297129
test t2 3 0 0 0 0 0 1 0
71307130
test t3 0 0 0 0 0 0 0 1

mysql-test/main/subselect_no_opts.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7120,8 +7120,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
71207120
MIN(b)
71217121
NULL
71227122
# The following shows that t2 was indeed scanned with a full scan.
7123-
show table_statistics;
7124-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
7123+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
7124+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
71257125
test t1 2 0 0 0 0 0 0 0
71267126
test t2 3 0 0 0 0 0 1 0
71277127
test t3 0 0 0 0 0 0 0 1

mysql-test/main/subselect_no_scache.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7131,8 +7131,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
71317131
MIN(b)
71327132
NULL
71337133
# The following shows that t2 was indeed scanned with a full scan.
7134-
show table_statistics;
7135-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
7134+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
7135+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
71367136
test t1 2 0 0 0 0 0 0 0
71377137
test t2 3 0 0 0 0 0 1 0
71387138
test t3 0 0 0 0 0 0 0 1

mysql-test/main/subselect_no_semijoin.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7120,8 +7120,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
71207120
MIN(b)
71217121
NULL
71227122
# The following shows that t2 was indeed scanned with a full scan.
7123-
show table_statistics;
7124-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
7123+
select TABLE_SCHEMA, TABLE_NAME, ROWS_READ, ROWS_CHANGED, ROWS_CHANGED_X_INDEXES, ROWS_INSERTED, ROWS_UPDATED, ROWS_DELETED, KEY_READ_HITS, KEY_READ_MISSES from information_schema.table_statistics;
7124+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
71257125
test t1 2 0 0 0 0 0 0 0
71267126
test t2 3 0 0 0 0 0 1 0
71277127
test t3 0 0 0 0 0 0 0 1

mysql-test/main/userstat.result

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ ROWS_UPDATED bigint(21) NO NULL
7676
ROWS_DELETED bigint(21) NO NULL
7777
KEY_READ_HITS bigint(21) NO NULL
7878
KEY_READ_MISSES bigint(21) NO NULL
79+
PAGES_ACCESSED bigint(21) NO NULL
80+
PAGES_READ_FROM_DISK bigint(21) NO NULL
7981
set @save_general_log=@@global.general_log;
8082
set @@global.general_log=0;
8183
set @@global.userstat=1;
@@ -150,9 +152,9 @@ set @@global.userstat=0;
150152
select * from information_schema.index_statistics;
151153
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
152154
select * from information_schema.table_statistics;
153-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
155+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
154156
show table_statistics;
155-
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
157+
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses Pages_accessed Pages_read_from_disk
156158
show index_statistics;
157159
Table_schema Table_name Index_name Rows_read Queries
158160
select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;;
@@ -200,7 +202,7 @@ flush index_statistics;
200202
select * from information_schema.index_statistics;
201203
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
202204
select * from information_schema.table_statistics;
203-
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
205+
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES PAGES_ACCESSED PAGES_READ_FROM_DISK
204206
show status like "%generic%";
205207
Variable_name Value
206208
Com_show_generic 2

0 commit comments

Comments
 (0)