You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed in our old admin panel that we had a lot of lazy loaded media relations. We didn't get a warning about it (for 2 years 😄), even with Model::preventLazyLoading(); enabled globally. The cause for this is that doing loadMissing() on each object in a loop doesn't trigger the exception even though it's technically an n+1 issue.
The solution to this is to always eager load relations manually in the controller, not in models or traits. Removing this would be a breaking change, but are you open to it? I expect a lot of package users have tons of n+1 media issues but aren't aware, unless you manually inspect the debug bar queries for each page you use media in collections.
The text was updated successfully, but these errors were encountered:
This concerns #2784
I noticed in our old admin panel that we had a lot of lazy loaded media relations. We didn't get a warning about it (for 2 years 😄), even with
Model::preventLazyLoading();
enabled globally. The cause for this is that doingloadMissing()
on each object in a loop doesn't trigger the exception even though it's technically an n+1 issue.The solution to this is to always eager load relations manually in the controller, not in models or traits. Removing this would be a breaking change, but are you open to it? I expect a lot of package users have tons of n+1 media issues but aren't aware, unless you manually inspect the debug bar queries for each page you use media in collections.
The text was updated successfully, but these errors were encountered: