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

Fix time based average stats #442

Merged
merged 9 commits into from
May 18, 2023

Conversation

zainkabani
Copy link
Contributor

@zainkabani zainkabani commented May 15, 2023

Some stat averages were being calculated incorrectly for example, average query time (latency) was being calculated by dividing the total query time by our stat period (15 seconds). Instead we should be dividing by the number of queries we observed in that stat period.

Also, I've removed the tracking of old stat total, to just tracking the current totals for the given stat period, and after that stat period completes the current totals are re-zeroed (similar to how pgbouncer does it)

@levkk
Copy link
Contributor

levkk commented May 15, 2023

Pgbouncer makes it look easy: https://github.com/pgbouncer/pgbouncer/blob/master/src/stats.c#L67 :)

@zainkabani zainkabani marked this pull request as ready for review May 15, 2023 19:02
@zainkabani zainkabani changed the title Fix time based stats Fix time based average stats May 15, 2023
@levkk levkk requested a review from magec May 15, 2023 23:12
@levkk levkk merged commit 7f57a89 into postgresml:main May 18, 2023
pub avg_xact_time: Arc<AtomicU64>,
pub avg_xact_count: Arc<AtomicU64>,
pub avg_wait_time: Arc<AtomicU64>,
total: AddressStatFields,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice refactor

Copy link
Collaborator

@magec magec left a comment

Choose a reason for hiding this comment

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

Looks good to me (it's merged either way).

@levkk
Copy link
Contributor

levkk commented May 18, 2023

Looks good to me (it's merged either way).

@magec Still wanted to get your eyes on this one and wanted to make sure you update and validate on your end. Thanks!

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.

3 participants