summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-01-07 19:37:47 +0100
committerSergei Golubchik <serg@mariadb.org>2021-01-11 21:54:47 +0100
commit63f91927870b41b8965e2a2a868abcc2b3672f68 (patch)
treec1f7e0f76168834f2aa0ee461a9ce1e07bed0408 /sql/sql_show.cc
parent4c448836d489bd5a25c7509e8a69309c3b0a8e72 (diff)
downloadmariadb-git-63f91927870b41b8965e2a2a868abcc2b3672f68.tar.gz
MDEV-17251 SHOW STATUS unnecessary calls calc_sum_of_all_status
1. only call calc_sum_of_all_status() if a global SHOW_xxx_STATUS variable is to be returned 2. only lock LOCK_status when copying global_status_var, but not when iterating all threads
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 79897429a4f..4294157cce3 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3580,6 +3580,16 @@ static bool show_status_array(THD *thd, const char *wild,
if (show_type == SHOW_SYS)
mysql_mutex_lock(&LOCK_global_system_variables);
+ else if (show_type >= SHOW_LONG_STATUS && scope == OPT_GLOBAL &&
+ !status_var->local_memory_used)
+ {
+ mysql_mutex_lock(&LOCK_status);
+ *status_var= global_status_var;
+ mysql_mutex_unlock(&LOCK_status);
+ calc_sum_of_all_status(status_var);
+ DBUG_ASSERT(status_var->local_memory_used);
+ }
+
pos= get_one_variable(thd, var, scope, show_type, status_var,
&charset, buff, &length);
@@ -3620,8 +3630,6 @@ uint calc_sum_of_all_status(STATUS_VAR *to)
I_List_iterator<THD> it(threads);
THD *tmp;
- /* Get global values as base */
- *to= global_status_var;
to->local_memory_used= 0;
/* Add to this status from existing threads */
@@ -7586,13 +7594,7 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
if (partial_cond)
partial_cond->val_int();
- if (scope == OPT_GLOBAL)
- {
- /* We only hold LOCK_status for summary status vars */
- mysql_mutex_lock(&LOCK_status);
- calc_sum_of_all_status(&tmp);
- mysql_mutex_unlock(&LOCK_status);
- }
+ tmp.local_memory_used= 0; // meaning tmp was not populated yet
mysql_mutex_lock(&LOCK_show_status);
res= show_status_array(thd, wild,