Eager loading a collection query to avoid N+1 problems in loops #8194
Answered
by
jasonvarga
aaronbushnell
asked this question in
Q&A
-
This might have been answered elsewhere, but I couldn't quite find it! Is it possible to eager or lazy load collections that call to relationships to avoid the dreaded N+1 problem? I've tried both of these with no luck — the category query still shows up as a duplicate query: \Statamic\Facades\Entry::query()
->where('collection', 'blog')
->with('blog_categories')
->paginate(12);
Statamic::tag('collection:blog')
->with('blog_categories')
->paginate(12)
->fetch() |
Beta Was this translation helpful? Give feedback.
Answered by
jasonvarga
May 26, 2023
Replies: 1 comment 1 reply
-
Not possible at the moment unfortunately, but we're definitely aware of it and want to figure it out at some point. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aaronbushnell
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not possible at the moment unfortunately, but we're definitely aware of it and want to figure it out at some point.