Skip to content

Conversation

kverstae
Copy link

I came across a situation where the way the user roles were fetched introduced N+1 queries in my application.

By changing the way user relations are fetched from user->roles()->get() to user->getRelationValue('roles'), we can use the potentially eagerly loaded roles-relation and avoid having to do too many database queries when the data is already available.

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.

1 participant