-
Laravel Tip: Use "Constrained Eager Loading" in @laravelphp if you now that a relationship might return thousands of models. I patched this in an app today, where we accidentally hydrated thousands models. 😐 Response went from 1.5s to 0.3s. Docs: laravel.com/docs/master/eloquent-relationships#constraining-eager-loads
-
Used memory on the server also immediately dropped by 8% 😅
-
Wrote a blog post about this in [checks notes] 2019. I remember that the same app sparked the idea for the post. Just forgot to apply the pattern everywhere in the app. 😬 stefanzweifel.io/posts/constrained-eager-loading-in-laravel