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

Remove N+1 from shared/_post view #318

Closed
sauloperez opened this issue Feb 1, 2018 · 4 comments
Closed

Remove N+1 from shared/_post view #318

sauloperez opened this issue Feb 1, 2018 · 4 comments

Comments

@sauloperez
Copy link
Collaborator

The line below is responsible for a N+1:

<%= link_to post.member.display_name_with_uid, post.user %>

Due to:

def member
@member ||= Member.find_by(user_id: user_id, organization_id: organization_id)
end

That method is going introduce N+1 every time is used, as it is very likely that is going to be used as part of a larger query.

We should rely on eager loading the members association when needed instead.

@gpks
Copy link

gpks commented Oct 2, 2018

I would love to try to fix this :)

@sauloperez
Copy link
Collaborator Author

Hi @gpks ! please go ahead. Keep in mind that the app has changed considerably recently so make sure you check the N+1 still exists first. Sorry for any inconvenience.

@enricostano
Copy link
Contributor

@sauloperez can we close this issue? It seems that the N+1 is not there anymore. Right?

@sauloperez
Copy link
Collaborator Author

It seems so. Let's close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants