mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-35720 Add query_time to statistics
Added Query_time (total time spent running queries) to status_variables. Other things: - Added SHOW_MICROSECOND_STATUS type that shows an ulonglong variable in microseconds converted to a double (in seconds). - Changed Busy_time and Cpu_time to use SHOW_MICROSECOND_STATUS, which simplified the code and avoids some double divisions for each query. Reviewed-by: Sergei Golubchik <serg@mariadb.org>
This commit is contained in:
@@ -1419,7 +1419,10 @@ void THD::update_stats(void)
|
||||
void THD::update_all_stats()
|
||||
{
|
||||
ulonglong end_cpu_time, end_utime;
|
||||
double busy_time, cpu_time;
|
||||
ulonglong busy_time, cpu_time;
|
||||
|
||||
status_var_add(status_var.query_time,
|
||||
(utime_after_query - utime_after_lock));
|
||||
|
||||
/* This is set at start of query if opt_userstat_running was set */
|
||||
if (!userstat_running)
|
||||
@@ -1427,10 +1430,10 @@ void THD::update_all_stats()
|
||||
|
||||
end_cpu_time= my_getcputime();
|
||||
end_utime= microsecond_interval_timer();
|
||||
busy_time= (end_utime - start_utime) / 1000000.0;
|
||||
cpu_time= (end_cpu_time - start_cpu_time) / 10000000.0;
|
||||
busy_time= end_utime - start_utime;
|
||||
cpu_time= end_cpu_time - start_cpu_time;
|
||||
/* In case there are bad values, 2629743 is the #seconds in a month. */
|
||||
if (cpu_time > 2629743.0)
|
||||
if (cpu_time > 2629743000000ULL)
|
||||
cpu_time= 0;
|
||||
status_var_add(status_var.cpu_time, cpu_time);
|
||||
status_var_add(status_var.busy_time, busy_time);
|
||||
@@ -1853,6 +1856,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
|
||||
to_var->table_open_cache_hits+= from_var->table_open_cache_hits;
|
||||
to_var->table_open_cache_misses+= from_var->table_open_cache_misses;
|
||||
to_var->table_open_cache_overflows+= from_var->table_open_cache_overflows;
|
||||
to_var->query_time+= from_var->query_time;
|
||||
|
||||
/*
|
||||
Update global_memory_used. We have to do this with atomic_add as the
|
||||
@@ -1910,6 +1914,7 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
|
||||
dec_var->table_open_cache_misses;
|
||||
to_var->table_open_cache_overflows+= from_var->table_open_cache_overflows -
|
||||
dec_var->table_open_cache_overflows;
|
||||
to_var->query_time+= from_var->query_time - dec_var->query_time;
|
||||
|
||||
/*
|
||||
We don't need to accumulate memory_used as these are not reset or used by
|
||||
|
Reference in New Issue
Block a user