Using Repository Pattern In Laravel 5 – Eloquent Relations And Eager Loading
Before we go to the main topic of the article, I’ll give you a short heads up for some design problems you may face. Recently one of my clients complained that some pages open very slowly. When I say very, I mean incredibly slow. So I’ve decided to debug that page and what I saw shocked me. Query section was showing that on that page was executed an staggering 16500+ queries!!
I found troubling part of the code responsible for that. It was 3 foreach loops, querying an attribute and it’s related attributes. It worked fine, until there was about 5.5k items in the database.
This post is submitted by our members. Submit a new post.
Tags: Tutorials Laravel 5 Laravel 5.1