How to handle N+1 problem? #2951
Answered
by
Arne1303
edpmasterindo
asked this question in
Performance
-
Beta Was this translation helpful? Give feedback.
Answered by
Arne1303
Feb 16, 2023
Replies: 1 comment 1 reply
-
I think the problem with eager loading is that you use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
edpmasterindo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the problem with eager loading is that you use
$user->roles()->pluck('name')
which makes a new request. Try using$user->roles->first()->name
when usingUser::with('roles')