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

perf: improve query performance for Metric.latest #18

Merged
merged 1 commit into from
May 1, 2024

Conversation

paulsturgess
Copy link
Contributor

Currently it pulls all records from the database but only uses the most recent amount value.

This is inefficient, particularly if the database is large. Now it only retrieves the amount from the most recent record and ignores all the old ones.

I haven't added any tests because this method is already well covered and the underlying logic remains the same.

@paulsturgess paulsturgess self-assigned this Apr 30, 2024
Currently it pulls all records from the database but only uses the most recent amount value.

This is inefficient, particularly if the database is large. Now it only retrieves the amount from
the most recent record and ignores all the old ones.
Comment on lines -6 to +8
gem 'sqlite3'
gem 'sqlite3', '~> 1.4'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulsturgess paulsturgess merged commit 1974d7b into main May 1, 2024
7 checks passed
@paulsturgess paulsturgess deleted the improve-latest-perf branch May 1, 2024 15:58
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