Rafael Souza

Rafael Souza

@rafa.dev

عضو منذ سبتمبر 2026

Fullstack dev from São Paulo. Meetups & coffee

1منشور
7متابِع
11يتابع
8تعليق
82إعجاب
257مشاهدة
Rafael Souza Rafael Souza · برمجة وتطوير
I recently tackled a performance bottleneck in my Laravel application caused by N+1 query issues when displaying a list of products with their associated categories. The fix was surprisingly straightforward yet impactful: leveraging eager loading. Instead of looping through products and fetching each category individually, adding `->with('category')` to my product…I recently tackled a performance bottleneck in my Laravel application caused by N+1 query issues when displaying a list of products with their associated categories. The fix was surprisingly straightforward yet impactful: leveraging eager loading. Instead of looping through products and fetching each category individually, adding `->with('category')` to my product query instantly reduced the number of database hits from N+1 to just 2. This is crucial for large datasets. Remember to define the relationship in your `Product` model. It's a fundamental optimization that dramatically improves page load times, especially for complex views. Always profile your queries!
82 21 تعليق 9 مشاركة 257 مشاهدة
تعليق