Skip to main content

Eloquent Performance Patterns

2h 12m 50s
English
Paid

Course description

Learn how to drastically improve the performance of your Laravel applications by pushing more work to the database, all while still using the Eloquent ORM.

Read more about the course

Performance issues suck. Customers are frustrated. Your servers are overloaded. Management is breathing down your neck.

You've already solved all your N+1 issues, added the necessary indexes, and you're even paying for the most expensive database server available. But despite all this, some things just feel impossible to build in a performant way.

  1. We can't paginate results in the database because they depend on authorization checks that happen in Laravel.

  2. We have to do some really complicated calculations on large data sets, which seems impossible without a real programming language like PHP.

  3. We can't sort results in the database, because we have to sort by values computed in our application.

So you invest months into different caching strategies to try and speed things up, but caching is hard. Every time you think you've solved a performance problem, you have a new caching problem to deal with instead.

I've been there and it sucks. So one day I decided “that's it, I'm going to figure out how to push all this work to the database if it kills me.” The results blew my mind.

By leveraging advanced database techniques, like sub queries, conditional aggregates, and aggressive use of scopes, pages that took 30+ seconds to load were now loading within 500ms!!

I've since spoken about Eloquent and database performance at both Laracon Online and Laracon US, and have written in-depth articles on the topic.


Watch Online

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

Watch Online Eloquent Performance Patterns

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

Comments

0 comments

Want to join the conversation?

Sign in to comment

Similar courses

Laravel 10 Build Complete Hotel Booking Reservation System

Laravel 10 Build Complete Hotel Booking Reservation System

Sources: udemy
Welcome to the course "Creating a Hotel Booking System on Laravel 10"! In this course, we will build fully functional software from scratch...
41 hours 7 minutes 15 seconds
DevOps Project: CICD with Git GitLab Jenkins and Laravel

DevOps Project: CICD with Git GitLab Jenkins and Laravel

Sources: udemy
Continuous Integration Continuous Delivery/Deployment (CICD) is a very important part of modern-day software release processes. As a matter of fact, you can not survive as a Dev...
4 hours 47 minutes 21 seconds
Master Laravel, Vue 3 & Inertia Full Stack 2023

Master Laravel, Vue 3 & Inertia Full Stack 2023

Sources: udemy
Learn Laravel together with Vue.js in this brand new, full-stack, project based course! Learn how to create a robust API in Laravel and a Single Page Application frontend in Vue...
35 hours 53 minutes 40 seconds
The Ultimate Guide to Building APIs and SPAs With Laravel and Nuxt 3

The Ultimate Guide to Building APIs and SPAs With Laravel and Nuxt 3

Sources: Server Side Up
The book "The Ultimate Guide to Building APIs and Single-page Applications with Laravel and Nuxt 3" is a detailed guide to building web and mobile...
4 hours 2 minutes 48 seconds
Laravel From Scratch Course | Build A Job Listing Application

Laravel From Scratch Course | Build A Job Listing Application

Sources: Brad Traversy
Learn Laravel from scratch by creating and deploying a full-fledged job site, including authentication, authorization, and saving job listings to bookmarks...
13 hours 20 minutes 36 seconds