From c7ff17a234121799d88d455680d790f9a8e769da Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 3 May 2016 16:03:04 -0400 Subject: [PATCH] [mysql] improving accuracy for query exec time. Fixes #2406. [mysql] removing unnecessary element from SQL query. --- checks.d/mysql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checks.d/mysql.py b/checks.d/mysql.py index cbace47ccc..7057ae5259 100644 --- a/checks.d/mysql.py +++ b/checks.d/mysql.py @@ -1188,7 +1188,7 @@ def _query_exec_time_per_schema(self, db): # Fetches the avg query execution time per schema and returns the # value in microseconds - sql_avg_query_run_time = """SELECT schema_name, SUM(count_star) cnt, ROUND(AVG(avg_timer_wait)/1000000) AS avg_us + sql_avg_query_run_time = """SELECT schema_name, ROUND((SUM(sum_timer_wait) / SUM(count_star)) / 1000000) AS avg_us FROM performance_schema.events_statements_summary_by_digest WHERE schema_name IS NOT NULL GROUP BY schema_name""" @@ -1204,7 +1204,7 @@ def _query_exec_time_per_schema(self, db): schema_query_avg_run_time = {} for row in cursor.fetchall(): schema_name = str(row[0]) - avg_us = long(row[2]) + avg_us = long(row[1]) # set the tag as the dictionary key schema_query_avg_run_time["schema:{0}".format(schema_name)] = avg_us