MDEV-33152 Add QUERIES to INDEX_STATISTICS
Other changes: - Do not collect index statistics for system tables like index_stats table_stats, performance_schema, information_schema etc as the user has no control of these and the generate noise in the statistics.
This commit is contained in:
parent
869e67c92f
commit
a00e99acca
@ -16,30 +16,32 @@ select count(*) from just_a_test where state = 'California';
|
|||||||
count(*)
|
count(*)
|
||||||
2
|
2
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='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
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
test just_a_test IND_just_a_test_first_name_last_name 1
|
test just_a_test IND_just_a_test_first_name_last_name 1 1
|
||||||
test just_a_test IND_just_a_test_state 2
|
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';
|
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
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
test just_a_test 18 5 5
|
test just_a_test 18 5 5
|
||||||
alter table just_a_test drop key IND_just_a_test_first_name_last_name;
|
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';
|
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
|
||||||
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
test just_a_test IND_just_a_test_state 2
|
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';
|
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
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
test just_a_test 23 5 5
|
test just_a_test 23 5 5
|
||||||
alter table just_a_test drop column state;
|
alter table just_a_test drop column state;
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='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
|
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';
|
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
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
test just_a_test 28 5 5
|
test just_a_test 28 5 5
|
||||||
drop table just_a_test;
|
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='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
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
|
drop table just_a_test;
|
||||||
select * from information_schema.table_statistics where table_schema='test' and table_name='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
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
|
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));
|
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));
|
||||||
insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'),
|
insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'),
|
||||||
(2,'fb','lb','china_b',22222222,'fb_lb@163.com','Arizona'),
|
(2,'fb','lb','china_b',22222222,'fb_lb@163.com','Arizona'),
|
||||||
@ -56,16 +58,16 @@ select count(*) from just_a_test where id between 2 and 4;
|
|||||||
count(*)
|
count(*)
|
||||||
3
|
3
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='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
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
test just_a_test PRIMARY 4
|
test just_a_test PRIMARY 4 1
|
||||||
test just_a_test first_name 1
|
test just_a_test first_name 1 1
|
||||||
test just_a_test state 2
|
test just_a_test state 2 1
|
||||||
select * from information_schema.table_statistics where table_schema='test' and table_name='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
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
test just_a_test 7 5 15
|
test just_a_test 7 5 15
|
||||||
drop table just_a_test;
|
drop table just_a_test;
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='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
|
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';
|
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
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
set global userstat=@save_userstat;
|
set global userstat=@save_userstat;
|
||||||
|
@ -24,9 +24,10 @@ select * from information_schema.table_statistics where table_schema='test' and
|
|||||||
alter table just_a_test drop column state;
|
alter table just_a_test drop column state;
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
|
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
|
||||||
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
|
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
|
||||||
drop table just_a_test;
|
|
||||||
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
|
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
|
||||||
|
drop table just_a_test;
|
||||||
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
|
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
|
||||||
|
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
|
||||||
#
|
#
|
||||||
# Test direct drop table
|
# Test direct drop table
|
||||||
#
|
#
|
||||||
|
@ -130,9 +130,9 @@ TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
|||||||
test T1 4 4 4
|
test T1 4 4 4
|
||||||
test t1 4 4 4
|
test t1 4 4 4
|
||||||
SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS ORDER BY BINARY TABLE_NAME;
|
SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS ORDER BY BINARY TABLE_NAME;
|
||||||
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
test T1 a 4
|
test T1 a 4 1
|
||||||
test t1 a 4
|
test t1 a 4 1
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DROP TABLE T1;
|
DROP TABLE T1;
|
||||||
SET GLOBAL userstat=DEFAULT;
|
SET GLOBAL userstat=DEFAULT;
|
||||||
|
@ -7128,8 +7128,8 @@ Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
|||||||
test t1 2 0 0
|
test t1 2 0 0
|
||||||
test t2 3 0 0
|
test t2 3 0 0
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
test t2 b 1
|
test t2 b 1 1
|
||||||
set global userstat=@tmp_mdev410;
|
set global userstat=@tmp_mdev410;
|
||||||
DROP TABLE t1,t2,t3,t4;
|
DROP TABLE t1,t2,t3,t4;
|
||||||
#
|
#
|
||||||
|
@ -7130,8 +7130,8 @@ Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
|||||||
test t1 2 0 0
|
test t1 2 0 0
|
||||||
test t2 3 0 0
|
test t2 3 0 0
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
test t2 b 1
|
test t2 b 1 1
|
||||||
set global userstat=@tmp_mdev410;
|
set global userstat=@tmp_mdev410;
|
||||||
DROP TABLE t1,t2,t3,t4;
|
DROP TABLE t1,t2,t3,t4;
|
||||||
#
|
#
|
||||||
|
@ -7126,8 +7126,8 @@ Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
|||||||
test t1 2 0 0
|
test t1 2 0 0
|
||||||
test t2 3 0 0
|
test t2 3 0 0
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
test t2 b 1
|
test t2 b 1 1
|
||||||
set global userstat=@tmp_mdev410;
|
set global userstat=@tmp_mdev410;
|
||||||
DROP TABLE t1,t2,t3,t4;
|
DROP TABLE t1,t2,t3,t4;
|
||||||
#
|
#
|
||||||
|
@ -7123,8 +7123,8 @@ Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
|||||||
test t1 2 0 0
|
test t1 2 0 0
|
||||||
test t2 3 0 0
|
test t2 3 0 0
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
test t2 b 1
|
test t2 b 1 1
|
||||||
set global userstat=@tmp_mdev410;
|
set global userstat=@tmp_mdev410;
|
||||||
DROP TABLE t1,t2,t3,t4;
|
DROP TABLE t1,t2,t3,t4;
|
||||||
#
|
#
|
||||||
|
@ -7134,8 +7134,8 @@ Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
|||||||
test t1 2 0 0
|
test t1 2 0 0
|
||||||
test t2 3 0 0
|
test t2 3 0 0
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
test t2 b 1
|
test t2 b 1 1
|
||||||
set global userstat=@tmp_mdev410;
|
set global userstat=@tmp_mdev410;
|
||||||
DROP TABLE t1,t2,t3,t4;
|
DROP TABLE t1,t2,t3,t4;
|
||||||
#
|
#
|
||||||
|
@ -7123,8 +7123,8 @@ Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
|||||||
test t1 2 0 0
|
test t1 2 0 0
|
||||||
test t2 3 0 0
|
test t2 3 0 0
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
test t2 b 1
|
test t2 b 1 1
|
||||||
set global userstat=@tmp_mdev410;
|
set global userstat=@tmp_mdev410;
|
||||||
DROP TABLE t1,t2,t3,t4;
|
DROP TABLE t1,t2,t3,t4;
|
||||||
#
|
#
|
||||||
|
@ -59,6 +59,7 @@ TABLE_SCHEMA varchar(192) NO NULL
|
|||||||
TABLE_NAME varchar(192) NO NULL
|
TABLE_NAME varchar(192) NO NULL
|
||||||
INDEX_NAME varchar(192) NO NULL
|
INDEX_NAME varchar(192) NO NULL
|
||||||
ROWS_READ bigint(21) NO NULL
|
ROWS_READ bigint(21) NO NULL
|
||||||
|
QUERIES bigint(21) NO NULL
|
||||||
show columns from information_schema.table_statistics;
|
show columns from information_schema.table_statistics;
|
||||||
Field Type Null Key Default Extra
|
Field Type Null Key Default Extra
|
||||||
TABLE_SCHEMA varchar(192) NO NULL
|
TABLE_SCHEMA varchar(192) NO NULL
|
||||||
@ -138,13 +139,13 @@ handler_read_key
|
|||||||
disconnect ssl_con;
|
disconnect ssl_con;
|
||||||
set @@global.userstat=0;
|
set @@global.userstat=0;
|
||||||
select * from information_schema.index_statistics;
|
select * from information_schema.index_statistics;
|
||||||
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
select * from information_schema.table_statistics;
|
select * from information_schema.table_statistics;
|
||||||
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
show table_statistics;
|
show table_statistics;
|
||||||
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
||||||
show index_statistics;
|
show index_statistics;
|
||||||
Table_schema Table_name Index_name Rows_read
|
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;;
|
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;;
|
||||||
TOTAL_CONNECTIONS 2
|
TOTAL_CONNECTIONS 2
|
||||||
TOTAL_SSL_CONNECTIONS 1
|
TOTAL_SSL_CONNECTIONS 1
|
||||||
@ -188,7 +189,7 @@ OTHER_COMMANDS IN (7,8)
|
|||||||
flush table_statistics;
|
flush table_statistics;
|
||||||
flush index_statistics;
|
flush index_statistics;
|
||||||
select * from information_schema.index_statistics;
|
select * from information_schema.index_statistics;
|
||||||
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ QUERIES
|
||||||
select * from information_schema.table_statistics;
|
select * from information_schema.table_statistics;
|
||||||
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
|
||||||
show status like "%generic%";
|
show status like "%generic%";
|
||||||
@ -248,3 +249,24 @@ drop function f;
|
|||||||
#
|
#
|
||||||
# End of 10.2 tests
|
# End of 10.2 tests
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for
|
||||||
|
# subqueries
|
||||||
|
#
|
||||||
|
SET @save_userstat= @@userstat;
|
||||||
|
set global userstat= 1;
|
||||||
|
create or replace table t1 (a int, key(a)) engine=MyISAM;
|
||||||
|
insert into t1 values (1),(2),(3),(4);
|
||||||
|
flush index_statistics;
|
||||||
|
select a from t1 where a in ( select a from t1 );
|
||||||
|
a
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
show index_statistics;
|
||||||
|
Table_schema Table_name Index_name Rows_read Queries
|
||||||
|
test t1 a 8 1
|
||||||
|
drop table t1;
|
||||||
|
set global userstat=@save_userstat;
|
||||||
|
# End of 11.5 tests
|
||||||
|
@ -133,3 +133,21 @@ drop function f;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.2 tests
|
--echo # End of 10.2 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-33901 INDEX_STATISTICS.QUERIES is incremented additionally for
|
||||||
|
--echo # subqueries
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SET @save_userstat= @@userstat;
|
||||||
|
set global userstat= 1;
|
||||||
|
|
||||||
|
create or replace table t1 (a int, key(a)) engine=MyISAM;
|
||||||
|
insert into t1 values (1),(2),(3),(4);
|
||||||
|
flush index_statistics;
|
||||||
|
select a from t1 where a in ( select a from t1 );
|
||||||
|
show index_statistics;
|
||||||
|
drop table t1;
|
||||||
|
set global userstat=@save_userstat;
|
||||||
|
|
||||||
|
--echo # End of 11.5 tests
|
||||||
|
@ -184,6 +184,7 @@ def information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL NO varchar 4096 12288
|
|||||||
def information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO
|
def information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO
|
||||||
def information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL NO varchar 4096 12288 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(4096) select NEVER NULL NO NO
|
def information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL NO varchar 4096 12288 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(4096) select NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS INDEX_NAME 3 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS INDEX_NAME 3 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL NO NO
|
||||||
|
def information_schema INDEX_STATISTICS QUERIES 5 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS ROWS_READ 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS ROWS_READ 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS TABLE_NAME 2 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS TABLE_NAME 2 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) select NEVER NULL NO NO
|
||||||
@ -779,6 +780,7 @@ NULL information_schema GEOMETRY_COLUMNS SRID smallint NULL NULL NULL NULL small
|
|||||||
3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
||||||
3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
||||||
NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21)
|
NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21)
|
||||||
|
NULL information_schema INDEX_STATISTICS QUERIES bigint NULL NULL NULL NULL bigint(21)
|
||||||
3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||||
3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
||||||
NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned
|
NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned
|
||||||
|
@ -184,6 +184,7 @@ def information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL NO varchar 4096 12288
|
|||||||
def information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) NEVER NULL NO NO
|
def information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) NEVER NULL NO NO
|
||||||
def information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL NO varchar 4096 12288 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(4096) NEVER NULL NO NO
|
def information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL NO varchar 4096 12288 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(4096) NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS INDEX_NAME 3 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS INDEX_NAME 3 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL NO NO
|
||||||
|
def information_schema INDEX_STATISTICS QUERIES 5 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS ROWS_READ 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS ROWS_READ 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS TABLE_NAME 2 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS TABLE_NAME 2 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL NO NO
|
||||||
def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL NO NO
|
def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NULL NO varchar 192 576 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(192) NEVER NULL NO NO
|
||||||
@ -779,6 +780,7 @@ NULL information_schema GEOMETRY_COLUMNS SRID smallint NULL NULL NULL NULL small
|
|||||||
3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
||||||
3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
||||||
NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21)
|
NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21)
|
||||||
|
NULL information_schema INDEX_STATISTICS QUERIES bigint NULL NULL NULL NULL bigint(21)
|
||||||
3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8mb3 utf8mb3_general_ci varchar(64)
|
||||||
3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8mb3 utf8mb3_general_ci varchar(192)
|
||||||
NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned
|
NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned
|
||||||
|
@ -6,6 +6,7 @@ static ST_FIELD_INFO index_stats_fields[]=
|
|||||||
Column("TABLE_NAME", Varchar(NAME_LEN), NOT_NULL, "Table_name"),
|
Column("TABLE_NAME", Varchar(NAME_LEN), NOT_NULL, "Table_name"),
|
||||||
Column("INDEX_NAME", Varchar(NAME_LEN), NOT_NULL, "Index_name"),
|
Column("INDEX_NAME", Varchar(NAME_LEN), NOT_NULL, "Index_name"),
|
||||||
Column("ROWS_READ", SLonglong(), NOT_NULL, "Rows_read"),
|
Column("ROWS_READ", SLonglong(), NOT_NULL, "Rows_read"),
|
||||||
|
Column("QUERIES", SLonglong(), NOT_NULL, "Queries"),
|
||||||
CEnd()
|
CEnd()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ static int index_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
system_charset_info);
|
system_charset_info);
|
||||||
table->field[2]->store(index_name, (uint) index_name_length, system_charset_info);
|
table->field[2]->store(index_name, (uint) index_name_length, system_charset_info);
|
||||||
table->field[3]->store((longlong)index_stats->rows_read, TRUE);
|
table->field[3]->store((longlong)index_stats->rows_read, TRUE);
|
||||||
|
table->field[4]->store((longlong)index_stats->queries, TRUE);
|
||||||
|
|
||||||
if (schema_table_store_record(thd, table))
|
if (schema_table_store_record(thd, table))
|
||||||
{
|
{
|
||||||
|
@ -6033,6 +6033,9 @@ void handler::update_global_index_stats()
|
|||||||
{
|
{
|
||||||
DBUG_ASSERT(table->s);
|
DBUG_ASSERT(table->s);
|
||||||
|
|
||||||
|
if (table->s->table_category != TABLE_CATEGORY_USER)
|
||||||
|
return; // Ignore stat tables, performance_schema, information_schema etc.
|
||||||
|
|
||||||
if (!table->in_use->userstat_running)
|
if (!table->in_use->userstat_running)
|
||||||
{
|
{
|
||||||
/* Reset all index read values */
|
/* Reset all index read values */
|
||||||
@ -6073,6 +6076,15 @@ void handler::update_global_index_stats()
|
|||||||
}
|
}
|
||||||
/* Updates the global index stats. */
|
/* Updates the global index stats. */
|
||||||
index_stats->rows_read+= index_rows_read[index];
|
index_stats->rows_read+= index_rows_read[index];
|
||||||
|
/*
|
||||||
|
Ensure we do not update queries if the table is used
|
||||||
|
twice in the same statement.
|
||||||
|
*/
|
||||||
|
if (index_stats->query_id != table->in_use->query_id)
|
||||||
|
{
|
||||||
|
index_stats->query_id= table->in_use->query_id;
|
||||||
|
index_stats->queries++;
|
||||||
|
}
|
||||||
index_rows_read[index]= 0;
|
index_rows_read[index]= 0;
|
||||||
end:
|
end:
|
||||||
mysql_mutex_unlock(&LOCK_global_index_stats);
|
mysql_mutex_unlock(&LOCK_global_index_stats);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "sql_bitmap.h"
|
#include "sql_bitmap.h"
|
||||||
#include "lex_charset.h"
|
#include "lex_charset.h"
|
||||||
#include "lex_ident.h"
|
#include "lex_ident.h"
|
||||||
|
#include "sql_basic_types.h" /* query_id_t */
|
||||||
|
|
||||||
struct TABLE;
|
struct TABLE;
|
||||||
class Type_handler;
|
class Type_handler;
|
||||||
@ -381,6 +382,8 @@ typedef struct st_index_stats
|
|||||||
char index[NAME_LEN * 3 + 3];
|
char index[NAME_LEN * 3 + 3];
|
||||||
size_t index_name_length; /* Length of 'index' */
|
size_t index_name_length; /* Length of 'index' */
|
||||||
ulonglong rows_read;
|
ulonglong rows_read;
|
||||||
|
ulonglong queries;
|
||||||
|
query_id_t query_id;
|
||||||
} INDEX_STATS;
|
} INDEX_STATS;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user