Eloquent Performance Challenge: My Solution Version

preview_player
Показать описание
Yesterday I published a new challenge, and with 40+ Pull Requests from you guys, I already have something to discuss. So let's start with my own initial version of the solution, and in the upcoming video(s) I will discuss your PRs.

Related links:

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

Really nice challenge, a small tip, when eager loading you can also specify the columns you want from the relationship like this ->with('category:id, name'), it doesn't really matter here since in this case this is a very minor performance boost, but relationship could have like 20 columns, and this way you are loading only those you need for the query :)

urosminic
Автор

I am not a PHP guy, I even don't like PHP. But I like to watch your videos, how you approach to the solutions, optimize things step by step.
Thanks for your videos. Keep making ❤️

pijushbarik
Автор

Thank you so much for this video, actually this was my first time using debugbar, and just following your tips I managed to reduce the queries in one of the pages from 800 queries to just 75, and from 1400 models to 40, also reduced memory from 26 mb to 15 mb.

You are awesome. Thank you. Keep it up.

AliAwwad
Автор

6:47 wow! that was soo cool and satisfying

oshidipe
Автор

$object->relation = returns results for the relationship as result of sql query
$object->relation() = returns query builder / eloquent instance on which one can perform other stuff.
Respect from Pakistan

nabeelyousafpasha
Автор

Thank you, wonderful explanation, you save my time once I googled how to minimize the number of query in model, but I didn't success, now I got idea how to optimize my queries.

nadeemahmed
Автор

This is best steps and very clear to refactoring query.
Waw! Need more cases

bboydarknesz
Автор

It's a wonderful sample that show what we do and what wee must do. Thanks

aldwynconjurer
Автор

Thanks as always. Mine is PR 48. And now I'm here to learn how to really improve it :)

belce
Автор

Good solution, we need more challenges.

ChangeYourLifeForever
Автор

Excellent video!! Thanks for this. Your explanation is perfect and solve a lot of questions for me. Thanks!

arthurarw
Автор

First of all, allow me give my loud of applause for your great content on laravel and programming generally. Your videos have really shaped my laravel skills 👏. I do have a problem when it comes to memory(debugbar measurement) which even in a small page with just 3 queries (perfectly optimized) doesn't still go below 23mb and page load speed at/around 200ms. Thank you

dennisjmaina
Автор

Lol love the fact that it says 1.42 sec and the vid takes 4 seconds to open the page hahahaha but thank this helped me a lot

kingstalker
Автор

I love these challenges. Very satisfiying.

am_yt
Автор

Perfect example, like frrom me, respect man!

jimishukurow
Автор

Hi sir, learn more alot from your videos. u use withCount and withAvg to a single relationship. Can you please make a video on aggregate relation methods like these and withSum for relationship's to relations like withSum('movies.category', 'column_name'). Thanks

naazimkhan
Автор

Thanks for the video. I have learnt a lot from your videos

raj-kal
Автор

I didn't know there weren't foreign keys yet. I just assumed there would be. It was a mistake to do so hahaha

avidian
Автор

Thanks. Very interestin. I also forgot to check indexes.... :(

GergelyCsermely
Автор

Hi Povilas, I learned a lot from you, please confirm one thing, while adding a foreign key you did not drop the column, it isn't necessary to drop a foreign key column?

satashanofficial