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

Hotfix / Improve scores feed performance #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

egondohr22
Copy link
Owner

Fixes: #1

Changes

When calling api/feed, every individual score queried for their respective user.
By changing:
scores = Score.all.order(played_at: :desc, id: :desc)
To:
scores = Score.all.includes(:user).order(played_at: :desc, id: :desc)
We load all the scores with their associated user at once, reducing the total number of queries.

Before

Screenshot 2023-08-02 at 4 24 12 PM

After

Screenshot 2023-08-02 at 4 24 30 PM

@cristian-scarisoreanu
Copy link

cristian-scarisoreanu commented Aug 3, 2023

The title should usually be Hotfix / [Name of the issue]

@egondohr22 egondohr22 changed the title Fix n+1 querries Hotfix / Improve scores feed performance Aug 3, 2023
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.

Improve scores feed performance
2 participants