_stefanzweifel’s avatar_stefanzweifel’s Twitter Archive—№ 2,166

  1. 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
    1. …in reply to @_stefanzweifel
      Used memory on the server also immediately dropped by 8% 😅
      1. …in reply to @_stefanzweifel
        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