Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Lazy loading protection does not catch all duplicate queries

I discovered this one the hard way

Joel Clermont
Joel Clermont
2025-09-19

From our daily Laravel tips email. Get the next one in your inbox.

Laravel has some nice protections against unintentional lazy loading (the dreaded "N+1" query), but it can't catch every possible duplicate query you might accidentally introduce.

In today's video, I show a real example of the type of bug that can slip through and make a case for why you should remain diligent when writing database access code inside of loops.

Watch Now (4 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. Would you like a performance review of your application? Check out our Laravel code review service.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.