Skip to main content
CF

Eloquent Performance Patterns

2h 12m 50s
English
Paid

Learn how to improve the speed of your Laravel apps by moving more work to the database while still using Eloquent. This course shows you clear steps you can use right away.

The Problem

Slow apps cause stress. Users wait. Servers work too hard. You feel pressure from every side.

You fix N+1 queries. You add indexes. You pay for stronger servers. But some tasks still feel slow and hard to build.

Common Roadblocks

  • You cannot paginate in the database because your checks run in Laravel.
  • You need heavy calculations on large data sets, and you think only PHP can handle them.
  • You sort by values created in your app, not in the database.

You try caching. It helps for a moment. Then you fight new cache bugs and stale data. The loop never ends.

A Different Path

I felt the same pain. So I set out to push as much work as possible to the database. I tested ideas. I broke things. I learned many patterns that changed how I build apps.

With tools like subqueries, conditional aggregates, and smart scopes, pages that once took over 30 seconds now load in under a second.

Why This Matters

I have shared these ideas at events like Laracon Online and Laracon US. I have also written articles on advanced Eloquent patterns.

About the Author: Jonathan Reinink

Jonathan Reinink thumbnail

Jonathan Reinink is a Canadian software engineer and the creator of Inertia.js — the modern monolith framework that lets Laravel and Rails developers build SPAs without the typical SPA complexity, by treating server-rendered pages and client-side React / Vue components as a unified stack.

His CourseFlix listing carries Eloquent Performance Patterns — a deep treatment of Laravel Eloquent ORM performance: the query patterns, the N+1 traps, eager loading strategies, and the engineering decisions that separate fast Eloquent code from the default slow patterns.

Material is paid and aimed at Laravel developers running Eloquent at scale. For broader content, see CourseFlix's Laravel category page.

Watch Online 28 lessons

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 28 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: Measuring your database performance
All Course Lessons (28)
#Lesson TitleDurationAccess
1
Measuring your database performance Demo
04:43
2
Minimizing memory usage by selecting only
04:29
3
Getting one record from has-many relationships
09:44
4
Creating dynamic relationships using sub queries
06:10
5
Calculating totals using conditional aggregates
04:21
6
Optimizing circular relationships
04:25
7
Setting up multi-column searching
04:07
8
Getting LIKE to use an index
05:05
9
Faster options than whereHas
03:55
10
When it makes sense to run additional queries
03:08
11
Using UNIONs to run queries independently
07:58
12
Fuzzier searching using regular expressions
04:45
13
Running authorization policies in the database
06:04
14
Faster ordering using compound indexes
04:05
15
Ordering by has-one relationships
01:38
16
Ordering by belongs-to relationships
01:39
17
Ordering by has-many relationships
04:21
18
Ordering by belongs-to-many relationships
05:39
19
Ordering with NULLs always last
07:36
20
Ordering by custom algorithms
06:38
21
Filtering and sorting anniversary dates
07:04
22
Making N+1 issues impossible
03:24
23
Ordering data for humans using natural sort
04:20
24
Full text searching with rankings
05:07
25
Getting the distance between geographic points
03:23
26
Filtering by geographic distance
03:00
27
Ordering by geographic distance
01:26
28
Filtering by geospatial area
04:36
Unlock unlimited learning

Get instant access to all 27 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription

Related courses

Frequently asked questions

What are the prerequisites for this course?
Before enrolling, you should have a solid understanding of Laravel and Eloquent ORM, as the course focuses on optimizing database operations using these tools. Familiarity with basic database concepts and SQL queries will also be beneficial, as the course involves advanced techniques like subqueries and conditional aggregates.
What will I build or achieve by the end of the course?
By the end of the course, you will be equipped with techniques to optimize Laravel applications, including reducing load times from over 30 seconds to under a second. You will learn to implement subqueries, conditional aggregates, and smart scopes, which will help you move more computational work to the database, increasing the efficiency of your applications.
Who is the target audience for this course?
This course is designed for Laravel developers who are experiencing performance issues in their applications and want to improve app speed by leveraging database capabilities. It's also suitable for those who have faced challenges with N+1 queries, heavy calculations, and data sorting within Laravel.
How does this course differ from other Laravel performance courses?
Unlike some other courses, this course specifically focuses on moving computational tasks to the database while using Eloquent ORM. It addresses common performance roadblocks like N+1 queries and sorting issues, offering practical steps to optimize database interactions without relying heavily on server resources or caching.
What specific tools or platforms will I learn about?
The course covers advanced Eloquent patterns and tools like subqueries, conditional aggregates, and smart scopes. It also touches on database indexing techniques, using UNIONs for query independence, and optimizing search and ordering operations with compound indexes and geospatial filtering.
What topics are not covered in this course?
The course does not cover basic Laravel setup or introductory concepts of Eloquent ORM. It also doesn't focus on server-side optimizations outside of database interactions, such as caching strategies or server scaling techniques. Instead, the emphasis is on optimizing database operations within Laravel applications.
How much time should I expect to commit to this course?
The course includes 28 lessons, but the total runtime is not specified. It is recommended to allocate time for each lesson to understand and apply the concepts thoroughly. Given the advanced nature of the content, setting aside time for practical experimentation and reviewing complex topics is advised.