MDEV-4981: Account for queries handled by query-cache in USER_STATISTICS (and in HOST_STATISTICS)
Added collection statistics for queries resolved via query cache.
This commit is contained in:
parent
eae0a45f4e
commit
2f4db5348a
@ -1932,6 +1932,85 @@ set local query_cache_type= on;
|
|||||||
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
|
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
|
||||||
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
|
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
|
||||||
20971520 ON ON
|
20971520 ON ON
|
||||||
|
#
|
||||||
|
# MDEV-4981: Account for queries handled by query-cache in
|
||||||
|
# USER_STATISTICS (and in HOST_STATISTICS)
|
||||||
|
#
|
||||||
|
SET GLOBAL userstat=1;
|
||||||
|
set GLOBAL query_cache_size=1355776;
|
||||||
|
FLUSH USER_STATISTICS;
|
||||||
|
FLUSH CLIENT_STATISTICS;
|
||||||
|
reset query cache;
|
||||||
|
flush status;
|
||||||
|
create table t1 (a int);
|
||||||
|
insert into t1 values (1);
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
1 1 0
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
2 2 0
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 0
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
1
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
5 5 0
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
6 6 0
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 2
|
||||||
|
drop table t1;
|
||||||
|
FLUSH USER_STATISTICS;
|
||||||
|
FLUSH CLIENT_STATISTICS;
|
||||||
|
flush status;
|
||||||
|
create table t1 (a int);
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
1 0 1
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
2 1 1
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 0
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
5 2 3
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
SELECT_COMMANDS ROWS_SENT EMPTY_QUERIES
|
||||||
|
6 3 3
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 2
|
||||||
|
drop table t1;
|
||||||
|
SET GLOBAL userstat=default;
|
||||||
|
End of 5.5 tests
|
||||||
restore defaults
|
restore defaults
|
||||||
SET GLOBAL query_cache_type= default;
|
SET GLOBAL query_cache_type= default;
|
||||||
SET GLOBAL query_cache_size= default;
|
SET GLOBAL query_cache_size= default;
|
||||||
|
@ -1617,6 +1617,58 @@ select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
|
|||||||
set local query_cache_type= on;
|
set local query_cache_type= on;
|
||||||
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
|
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-4981: Account for queries handled by query-cache in
|
||||||
|
--echo # USER_STATISTICS (and in HOST_STATISTICS)
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SET GLOBAL userstat=1;
|
||||||
|
set GLOBAL query_cache_size=1355776;
|
||||||
|
FLUSH USER_STATISTICS;
|
||||||
|
FLUSH CLIENT_STATISTICS;
|
||||||
|
reset query cache;
|
||||||
|
flush status;
|
||||||
|
|
||||||
|
create table t1 (a int);
|
||||||
|
insert into t1 values (1);
|
||||||
|
select * from t1;
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
select * from t1;
|
||||||
|
select * from t1;
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
FLUSH USER_STATISTICS;
|
||||||
|
FLUSH CLIENT_STATISTICS;
|
||||||
|
flush status;
|
||||||
|
|
||||||
|
create table t1 (a int);
|
||||||
|
select * from t1;
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
select * from t1;
|
||||||
|
select * from t1;
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.CLIENT_STATISTICS
|
||||||
|
where CLIENT="localhost";
|
||||||
|
select SELECT_COMMANDS,ROWS_SENT,EMPTY_QUERIES from INFORMATION_SCHEMA.USER_STATISTICS
|
||||||
|
where USER="root";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
SET GLOBAL userstat=default;
|
||||||
|
|
||||||
|
--echo End of 5.5 tests
|
||||||
|
|
||||||
--echo restore defaults
|
--echo restore defaults
|
||||||
SET GLOBAL query_cache_type= default;
|
SET GLOBAL query_cache_type= default;
|
||||||
|
@ -2074,9 +2074,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
|||||||
}
|
}
|
||||||
#endif /*!EMBEDDED_LIBRARY*/
|
#endif /*!EMBEDDED_LIBRARY*/
|
||||||
|
|
||||||
thd->limit_found_rows = query->found_rows();
|
thd->sent_row_count= thd->limit_found_rows = query->found_rows();
|
||||||
thd->status_var.last_query_cost= 0.0;
|
thd->status_var.last_query_cost= 0.0;
|
||||||
thd->query_plan_flags= (thd->query_plan_flags & ~QPLAN_QC_NO) | QPLAN_QC;
|
thd->query_plan_flags= (thd->query_plan_flags & ~QPLAN_QC_NO) | QPLAN_QC;
|
||||||
|
if (!thd->sent_row_count)
|
||||||
|
status_var_increment(thd->status_var.empty_queries);
|
||||||
|
else
|
||||||
|
status_var_add(thd->status_var.rows_sent, thd->sent_row_count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
End the statement transaction potentially started by an
|
End the statement transaction potentially started by an
|
||||||
|
@ -4656,6 +4656,7 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
|
|||||||
/* Count number of empty select queries */
|
/* Count number of empty select queries */
|
||||||
if (!thd->sent_row_count)
|
if (!thd->sent_row_count)
|
||||||
status_var_increment(thd->status_var.empty_queries);
|
status_var_increment(thd->status_var.empty_queries);
|
||||||
|
else
|
||||||
status_var_add(thd->status_var.rows_sent, thd->sent_row_count);
|
status_var_add(thd->status_var.rows_sent, thd->sent_row_count);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -5790,6 +5791,8 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
|
|||||||
{
|
{
|
||||||
/* Update statistics for getting the query from the cache */
|
/* Update statistics for getting the query from the cache */
|
||||||
thd->lex->sql_command= SQLCOM_SELECT;
|
thd->lex->sql_command= SQLCOM_SELECT;
|
||||||
|
status_var_increment(thd->status_var.com_stat[thd->lex->sql_command]);
|
||||||
|
thd->update_stats();
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user