Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mysql] improving accuracy for query exec time. Fixes issue #2406. #2463

Merged
merged 1 commit into from
May 6, 2016

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented May 3, 2016

See #2406.

  • ROUND((SUM(sum_timer_wait) / SUM(count_star)) / 1000000): represents the real average timer_wait per query for a given schema. Here, sum_timer_wait represents the sum of all timer_wait times for a certain query, and count_star is the number of times a certain query was run.
  • formerly ROUND(AVG(avg_timer_wait)/1000000) actually represented the average of averages.

The discrepancy between the two computations may be considerable.

@truthbk truthbk changed the title [mysql] improving accuracy for query exec time. Fixes #2406. [mysql] improving accuracy for query exec time. Fixes issue #2406. May 3, 2016
@olivielpeau olivielpeau added this to the 5.8.0 milestone May 4, 2016
@olivielpeau olivielpeau self-assigned this May 5, 2016
@@ -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, SUM(count_star) cnt, ROUND((SUM(sum_timer_wait) / SUM(count_star)) / 1000000) AS avg_us
Copy link
Member

Choose a reason for hiding this comment

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

kind of unrelated, but we could remove SUM(count_star) cnt from the SELECT as we don't use it right?

@olivielpeau
Copy link
Member

Had only one comment, feel free to ignore it though. Looks good to me! 👍

[mysql] removing unnecessary element from SQL query.
@truthbk truthbk force-pushed the jaime/mysql_avgfix branch from 3b51056 to c7ff17a Compare May 5, 2016 22:30
@truthbk
Copy link
Member Author

truthbk commented May 6, 2016

Addressed @olivielpeau comment. Tested, CI tests passing, so merging. :)

@truthbk truthbk merged commit 367d04b into master May 6, 2016
@truthbk truthbk deleted the jaime/mysql_avgfix branch May 6, 2016 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants