Commit ecc79611 authored by Monty's avatar Monty

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.
parent d1af7fde
......@@ -20,15 +20,15 @@ TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
test just_a_test IND_just_a_test_first_name_last_name 1 1
test just_a_test IND_just_a_test_state 2 1
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test just_a_test 18 5 5 5 0 0 2 0
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
test just_a_test 18 5 5 5 0 0 2 0 0 0
alter table just_a_test drop key IND_just_a_test_first_name_last_name;
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
test just_a_test IND_just_a_test_state 2 1
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test just_a_test 23 5 5 5 0 0 2 0
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
test just_a_test 23 5 5 5 0 0 2 0 0 0
alter table just_a_test drop column state;
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
......@@ -40,18 +40,18 @@ select * from just_a_test force index(primary) where id=8;
id first_name last_name address phone email
update just_a_test set first_name="unlucky" where id=5;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test just_a_test 31 6 6 5 1 0 4 1
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
test just_a_test 31 6 6 5 1 0 4 1 0 0
delete from just_a_test where id=5;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test just_a_test 32 7 7 5 1 1 5 1
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
test just_a_test 32 7 7 5 1 1 5 1 0 0
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
test just_a_test PRIMARY 4 3
drop table just_a_test;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
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
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
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
test just_a_test first_name 1 1
test just_a_test state 2 1
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test just_a_test 7 5 15 5 0 0 3 0
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
test just_a_test 7 5 15 5 0 0 3 0 0 0
drop table just_a_test;
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
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
set global userstat=@save_userstat;
# End of 11.5 tests
......@@ -129,9 +129,9 @@ a
3
4
SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS ORDER BY BINARY TABLE_NAME;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test T1 4 4 4 4 0 0 0 0
test t1 4 4 4 4 0 0 0 0
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
test T1 4 4 4 4 0 0 0 0 0 0
test t1 4 4 4 4 0 0 0 0 0 0
SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS ORDER BY BINARY TABLE_NAME;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
test T1 a 4 1
......
......@@ -7125,8 +7125,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
MIN(b)
NULL
# The following shows that t2 was indeed scanned with a full scan.
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test t1 2 0 0 0 0 0 0 0
test t2 3 0 0 0 0 0 1 0
test t3 0 0 0 0 0 0 0 1
......
......@@ -5954,8 +5954,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
--enable_ps2_protocol
--echo # The following shows that t2 was indeed scanned with a full scan.
--sorted_result
show table_statistics;
--sorted_result
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;
show index_statistics;
set global userstat=@tmp_mdev410;
......
......@@ -7127,8 +7127,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
MIN(b)
NULL
# The following shows that t2 was indeed scanned with a full scan.
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test t1 2 0 0 0 0 0 0 0
test t2 3 0 0 0 0 0 1 0
test t3 0 0 0 0 0 0 0 1
......
......@@ -7123,8 +7123,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
MIN(b)
NULL
# The following shows that t2 was indeed scanned with a full scan.
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test t1 2 0 0 0 0 0 0 0
test t2 3 0 0 0 0 0 1 0
test t3 0 0 0 0 0 0 0 1
......
......@@ -7120,8 +7120,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
MIN(b)
NULL
# The following shows that t2 was indeed scanned with a full scan.
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test t1 2 0 0 0 0 0 0 0
test t2 3 0 0 0 0 0 1 0
test t3 0 0 0 0 0 0 0 1
......
......@@ -7131,8 +7131,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
MIN(b)
NULL
# The following shows that t2 was indeed scanned with a full scan.
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test t1 2 0 0 0 0 0 0 0
test t2 3 0 0 0 0 0 1 0
test t3 0 0 0 0 0 0 0 1
......
......@@ -7120,8 +7120,8 @@ WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
MIN(b)
NULL
# The following shows that t2 was indeed scanned with a full scan.
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test t1 2 0 0 0 0 0 0 0
test t2 3 0 0 0 0 0 1 0
test t3 0 0 0 0 0 0 0 1
......
......@@ -76,6 +76,8 @@ ROWS_UPDATED bigint(21) NO NULL
ROWS_DELETED bigint(21) NO NULL
KEY_READ_HITS bigint(21) NO NULL
KEY_READ_MISSES bigint(21) NO NULL
PAGES_ACCESSED bigint(21) NO NULL
PAGES_READ_FROM_DISK bigint(21) NO NULL
set @save_general_log=@@global.general_log;
set @@global.general_log=0;
set @@global.userstat=1;
......@@ -150,9 +152,9 @@ set @@global.userstat=0;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
select * from information_schema.table_statistics;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
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
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Rows_inserted Rows_updated Rows_deleted Key_read_hits Key_read_misses
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
show index_statistics;
Table_schema Table_name Index_name Rows_read Queries
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;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
select * from information_schema.table_statistics;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
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
show status like "%generic%";
Variable_name Value
Com_show_generic 2
......
......@@ -471,6 +471,8 @@ def information_schema TABLE_PRIVILEGES TABLE_NAME 4 NULL NO varchar 64 192 NULL
def information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS KEY_READ_HITS 9 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS KEY_READ_MISSES 10 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS PAGES_ACCESSED 11 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS PAGES_READ_FROM_DISK 12 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS ROWS_CHANGED 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES 5 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
def information_schema TABLE_STATISTICS ROWS_DELETED 8 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
......@@ -1085,6 +1087,8 @@ NULL information_schema TABLE_STATISTICS ROWS_UPDATED bigint NULL NULL NULL NULL
NULL information_schema TABLE_STATISTICS ROWS_DELETED bigint NULL NULL NULL NULL bigint(21)
NULL information_schema TABLE_STATISTICS KEY_READ_HITS bigint NULL NULL NULL NULL bigint(21)
NULL information_schema TABLE_STATISTICS KEY_READ_MISSES bigint NULL NULL NULL NULL bigint(21)
NULL information_schema TABLE_STATISTICS PAGES_ACCESSED bigint NULL NULL NULL NULL bigint(21)
NULL information_schema TABLE_STATISTICS PAGES_READ_FROM_DISK bigint NULL NULL NULL NULL bigint(21)
3.0000 information_schema TRIGGERS TRIGGER_CATALOG varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
3.0000 information_schema TRIGGERS TRIGGER_SCHEMA varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
3.0000 information_schema TRIGGERS TRIGGER_NAME varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
......
......@@ -6,14 +6,18 @@ SET @userstat_old= @@userstat;
SET GLOBAL userstat=ON;
CREATE TABLE t1 (id int(10), PRIMARY KEY (id));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
SELECT COUNT(*) FROM t1;
COUNT(*)
10
FLUSH TABLE_STATISTICS;
SELECT SUM(id) FROM t1;
SUM(id)
55
SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
ROWS_READ
10
SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1';
ROWS_READ
SELECT PAGES_ACCESSED, PAGES_READ_FROM_DISK FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
PAGES_ACCESSED PAGES_READ_FROM_DISK
1 0
FLUSH TABLE_STATISTICS;
SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
ROWS_READ
......@@ -34,12 +38,12 @@ DROP TABLE t1;
CREATE TABLE t2 (c1 INT UNSIGNED);
ALTER TABLE t2 MODIFY c1 FLOAT;
SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t2';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
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
DROP TABLE t2;
CREATE TABLE t2 (c1 INT UNSIGNED);
ALTER TABLE t2 MODIFY c1 FLOAT;
SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t2';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
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
DROP TABLE t2;
SET GLOBAL userstat= @userstat_old;
SET SESSION default_storage_engine = @default_storage_engine_old;
# include file to test index and table statstics for specific storage engine
# requires includer set the default strorage engine for the session
# requires includer set the default storage engine for the session
# Bug 602047 (wrong rows_read value)
......@@ -12,10 +12,13 @@ SET GLOBAL userstat=ON;
--disable_ps2_protocol
CREATE TABLE t1 (id int(10), PRIMARY KEY (id));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
SELECT COUNT(*) FROM t1;
FLUSH TABLE_STATISTICS;
SELECT SUM(id) FROM t1;
SELECT ROWS_READ FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
SELECT ROWS_READ FROM INFORMATION_SCHEMA.INDEX_STATISTICS WHERE TABLE_NAME='t1';
SELECT PAGES_ACCESSED, PAGES_READ_FROM_DISK FROM INFORMATION_SCHEMA.TABLE_STATISTICS WHERE TABLE_NAME='t1';
# Test that FLUSH clears one table but not another
FLUSH TABLE_STATISTICS;
......
......@@ -12,6 +12,8 @@ static ST_FIELD_INFO table_stats_fields[]=
Column("ROWS_DELETED", SLonglong(), NOT_NULL, "Rows_deleted"),
Column("KEY_READ_HITS", SLonglong(), NOT_NULL, "Key_read_hits"),
Column("KEY_READ_MISSES", SLonglong(), NOT_NULL, "Key_read_misses"),
Column("PAGES_ACCESSED", SLonglong(), NOT_NULL, "Pages_accessed"),
Column("PAGES_READ_FROM_DISK", SLonglong(), NOT_NULL, "Pages_read_from_disk"),
CEnd()
};
......@@ -62,6 +64,8 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
table->field[7]->store((longlong) rows_stats->deleted, TRUE);
table->field[8]->store((longlong) rows_stats->key_read_hit, TRUE);
table->field[9]->store((longlong) rows_stats->key_read_miss, TRUE);
table->field[10]->store((longlong) rows_stats->pages_accessed, TRUE);
table->field[11]->store((longlong) rows_stats->pages_read_count, TRUE);
if (schema_table_store_record(thd, table))
{
......
......@@ -6088,6 +6088,8 @@ void handler::update_global_table_stats()
table_stats->rows_stats.deleted+= rows_stats.deleted;
table_stats->rows_stats.key_read_hit+= rows_stats.key_read_hit;
table_stats->rows_stats.key_read_miss+= rows_stats.key_read_miss;
table_stats->rows_stats.pages_accessed+= handler_stats->pages_accessed;
table_stats->rows_stats.pages_read_count+= handler_stats->pages_read_count;
changed= rows_stats.updated + rows_stats.inserted + rows_stats.deleted;
table_stats->rows_changed_x_indexes+= (changed *
(table->s->keys ? table->s->keys :
......
......@@ -5976,8 +5976,8 @@ class THD: public THD_count, /* this must be first */
bool should_collect_handler_stats() const
{
return (variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE) ||
lex->analyze_stmt;
return ((variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE) ||
userstat_running || lex->analyze_stmt);
}
/* Return true if we should create a note when an unusable key is found */
......
......@@ -349,6 +349,8 @@ struct rows_stats
ha_rows updated;
ha_rows inserted;
ha_rows deleted;
ha_rows pages_accessed;
ha_rows pages_read_count; // Read from disk
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment