Faster Laravel 5 ORM queries examples

I’ve put together a few example queries and speed tests for them so you can learn how to build faster queries. Hope it helps someone. If it does leave a comment, thanks!
Example query relationship through whereHas
Example query relationship through whereHas
Analysis: slow as fk… 25.88s
Tweaked it to grab customers first and store them, then use the collection filter function.
Tweaked it to grab customers first and store them, then use the collection filter function.
Analysis: much much faster!!! 2.39s
And then put it into Laravel cache.
Analysis Much faster.
Another way to do it if your just after counts.
More coming soon…
Fullstack4u.com shares web development tips for full stack web technologies and is helping share the passion to web developers worldwide.

Leave a Reply

Your email address will not be published. Required fields are marked *