Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,12 @@
#define HAVE_QUERY_CACHE 1
#define BIG_TABLES 1

/*
Query cache stats, should be used with qc_info plugin (MDEV-4682)
Should be turned off by default?
*/
#define HAVE_QUERY_CACHE_STATS 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncomment to use statistics


/*
Important storage engines (those that really need define
WITH_<ENGINE>_STORAGE_ENGINE for the whole server)
Expand Down
20 changes: 15 additions & 5 deletions mysql-test/suite/plugins/r/qc_info.result
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
set global query_cache_size=1355776;
create table t1 (a int not null);
create table t1 (a int not null) engine=myisam;
insert into t1 values (1),(2),(3);
select * from t1;
a
1
2
3
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_queries;
statement_schema statement_text result_blocks_count result_blocks_size
test select * from t1 1 512
select `schema`,`table` from information_schema.query_cache_queries_tables;
schema table
test t1
select `table_schema`,`table_name` from information_schema.query_cache_tables;
table_schema table_name
test t1
drop table t1;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_queries;
statement_schema statement_text result_blocks_count result_blocks_size
set global query_cache_size = 0;
select * from information_schema.query_cache_info;
STATEMENT_SCHEMA STATEMENT_TEXT RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED
select * from information_schema.query_cache_queries;
QUERY_CACHE_ID STATEMENT_SCHEMA STATEMENT_TEXT RESULT_FOUND_ROWS QUERY_ROWS SELECT_ROWS_READ QUERY_HITS QUERY_HITS_PERIOD_LOW QUERY_HITS_PERIOD_HIGH QUERY_HITS_PERIOD_OUTLIERS QUERY_HITS_TOTAL_TIME_US QUERY_HITS_MEAN_PERIOD_US QUERY_HITS_MEAN_PERIOD_LOW_US QUERY_HITS_MEAN_PERIOD_HIGH_US QUERY_INSERT_TIME QUERY_LAST_HIT_TIME SELECT_EXPEND_TIME_US SELECT_LOCK_TIME_US TABLES_TYPE RESULT_LENGTH RESULT_BLOCKS_COUNT RESULT_BLOCKS_SIZE RESULT_BLOCKS_SIZE_USED FLAGS_CLIENT_LONG_FLAG FLAGS_CLIENT_PROTOCOL_41 FLAGS_PROTOCOL_TYPE FLAGS_MORE_RESULTS_EXISTS FLAGS_IN_TRANS FLAGS_AUTOCOMMIT FLAGS_PKT_NR FLAGS_CHARACTER_SET_CLIENT FLAGS_CHARACTER_SET_RESULTS FLAGS_COLLATION_CONNECTION FLAGS_LIMIT FLAGS_TIME_ZONE FLAGS_SQL_MODE FLAGS_MAX_SORT_LENGTH FLAGS_GROUP_CONCAT_MAX_LEN FLAGS_DIV_PRECISION_INCREMENT FLAGS_DEFAULT_WEEK_FORMAT FLAGS_LC_TIME_NAMES
select * from information_schema.query_cache_queries_tables;
QUERY_CACHE_ID SCHEMA TABLE
select * from information_schema.query_cache_tables;
TABLE_SCHEMA TABLE_NAME TABLE_HASHED TABLE_TYPE QUERIES_IN_CACHE
set global query_cache_size= default;
12 changes: 9 additions & 3 deletions mysql-test/suite/plugins/r/qc_info_priv.result
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
set global query_cache_size=1355776;
create table t1 (a int not null);
create table t1 (a int not null) engine=myisam;
insert into t1 values (1),(2),(3);
select * from t1;
a
1
2
3
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_queries;
statement_schema statement_text result_blocks_count result_blocks_size
test select * from t1 1 512
select `schema`,`table` from information_schema.query_cache_queries_tables;
schema table
test t1
select `table_schema`,`table_name` from information_schema.query_cache_tables;
table_schema table_name
test t1
create user mysqltest;
select a from t1;
a
1
2
3
select count(*) from information_schema.query_cache_info;
select count(*) from information_schema.query_cache_queries;
count(*)
0
drop user mysqltest;
Expand Down
6 changes: 4 additions & 2 deletions mysql-test/suite/plugins/t/qc_info.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

drop table t1;
# the query was invalidated
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_queries;

set global query_cache_size = 0;
select * from information_schema.query_cache_info;
select * from information_schema.query_cache_queries;
select * from information_schema.query_cache_queries_tables;
select * from information_schema.query_cache_tables;

set global query_cache_size= default;

18 changes: 14 additions & 4 deletions mysql-test/suite/plugins/t/qc_info_init.inc
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'query_cache_info' and plugin_status='active'`)
if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'query_cache_queries' and plugin_status='active'`)
{
--skip QUERY_CACHE_INFO plugin is not active
--skip QUERY_CACHE_QUERIES plugin is not active
}
if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'query_cache_queries_tables' and plugin_status='active'`)
{
--skip QUERY_CACHE_QUERIES_TABLES plugin is not active
}
if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'query_cache_tables' and plugin_status='active'`)
{
--skip QUERY_CACHE_TABLES plugin is not active
}

set global query_cache_size=1355776;

create table t1 (a int not null);
create table t1 (a int not null) engine=myisam;
insert into t1 values (1),(2),(3);
select * from t1;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info;
select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_queries;
select `schema`,`table` from information_schema.query_cache_queries_tables;
select `table_schema`,`table_name` from information_schema.query_cache_tables;

4 changes: 3 additions & 1 deletion mysql-test/suite/plugins/t/qc_info_init.opt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
--loose-query_cache_info
--loose-query_cache_queries
--loose-query_cache_queries_tables
--loose-query_cache_tables
--plugin-load-add=$QUERY_CACHE_INFO_SO
2 changes: 1 addition & 1 deletion mysql-test/suite/plugins/t/qc_info_priv.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ create user mysqltest;
connect (conn1,localhost,mysqltest,,);
connection conn1;
select a from t1;
select count(*) from information_schema.query_cache_info;
select count(*) from information_schema.query_cache_queries;
connection default;
drop user mysqltest;
drop table t1;
Expand Down
Loading