Eloquent Performance Patterns

Eloquent Performance Patterns
Eloquent Performance Patterns
English | MP4 | AVC 2560×1440 | AAC 44KHz 2ch | 2h 12m | 2.05 GB

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.

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.

We can’t paginate results in the database because they depend on authorization checks that happen in Laravel.
We have to do some really complicated calculations on large data sets, which seems impossible without a real programming language like PHP.
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.

Eloquent Performance Patterns is a culmination of everything I’ve learned along my journey, distilled into a single course. We’re going to dig deep into advanced real world problems. This isn’t another Eloquent introduction course.

What you’ll learn

  • The three key metrics to better database performance
  • The incredible power of sub queries
  • When to use joins vs sub queries
  • Using sub queries to select related data
  • Using sub queries to build dynamic relationships
  • Using sub queries to order by related data
  • Calculating totals using conditional aggregates
  • Running authorization policies in the database
  • Building complex search filters
  • Extending the query builder using macros
  • Demystifying database indexes
  • Introducing complex queries without sacrificing Eloquent’s API
  • Leveraging vendor-specific (MySQL, Postgres, etc.) features
  • Caching and database denormalization
  • How to safely write raw database queries
  • Configuring Laravel to make N+1 issues impossible
  • Extending Eloquent to support ordering with NULLS LAST and NULLS FIRST
  • Getting the distance between two geographic points
  • Filtering by geographic distance
  • Ordering by geographic distance
  • Querying records within a physical area using geospatial shapes
Table of Contents

1 Measuring your database performance
2 Minimizing memory usage by selecting only
3 Getting one record from has-many relationships
4 Creating dynamic relationships using sub queries
5 Calculating totals using conditional aggregates
6 Optimizing circular relationships
7 Setting up multi-column searching
8 Getting LIKE to use an index
9 Faster options than whereHas
10 When it makes sense to run additional queries
11 Using UNIONs to run queries independently
12 Fuzzier searching using regular expressions
13 Running authorization policies in the database
14 Faster ordering using compound indexes
15 Ordering by has-one relationships
16 Ordering by belongs-to relationships
17 Ordering by has-many relationships
18 Ordering by belongs-to-many relationships
19 Ordering with NULLs always last
20 Ordering by custom algorithms
21 Filtering and sorting anniversary dates
22 Making N+1 issues impossible
23 Ordering data for humans using natural sort
24 Full text searching with rankings
25 Getting the distance between geographic points
26 Filtering by geographic distance
27 Ordering by geographic distance
28 Filtering by geospatial area