Тёмный

Optimizing Eloquent: Running Out Of Memory? 

Laravel Daily
Подписаться 141 тыс.
Просмотров 43 тыс.
50% 1

While optimizing Eloquent and DB performance in Laravel projects, it's not always about the number of queries or slowness of an individual query. There's one more important thing, let me show you, with an example.
- - - - -
Try our Laravel QuickAdminPanel: bit.ly/quickadminpanel
Enroll in my Laravel courses: laraveldaily.teachable.com

Хобби

Опубликовано:

 

14 июл 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 99   
@LaravelDaily
@LaravelDaily 4 года назад
If you want more tips on Eloquent and optimization, I have a full 4-hour course "Eloquent: Expert Level" laraveldaily.teachable.com/p/laravel-eloquent-expert-level
@q4h4r26
@q4h4r26 4 года назад
it's got to be a crime to have all these useful information for free sir ! i've got mad respect for you !
@muhammadumarsotvoldiev8768
@muhammadumarsotvoldiev8768 2 месяца назад
Thank you very much From Uzbekistan Fergana!
@henrybui_io
@henrybui_io 3 года назад
Amazing! When working with the big amount of models, I usually use pagination instead of loading all at the first time.
@danorex9100
@danorex9100 4 года назад
And finally we can use pagination to limit the amount of data.
@alexrusin
@alexrusin 4 года назад
And finally we can use select to limit the amount of data.
@NINJA29A
@NINJA29A 2 года назад
Exactly
@FortinhoTV
@FortinhoTV 4 года назад
I still didn't work with laravel, just trying to learn to begin a project. Your tips are of great value.
@gushung0
@gushung0 4 года назад
WOW, this is an amazing tut. Thank YOU!!!
@vitouvitou5269
@vitouvitou5269 4 года назад
Thanks so much and i enjoy your tutorial every days.
@emilianovargas
@emilianovargas 4 года назад
This tut has great value. Thanks a lot!
@TahirBhai
@TahirBhai 4 года назад
Great tips about Eloquent. One more thing we can do is not to load * all data but we can put select() to only get required columns which we are going to show in blade view. It will also help to improve queries speed.
@mdmohithasan1838
@mdmohithasan1838 Год назад
Very knowledgable video, thanks a lot.
@alexrusin
@alexrusin 4 года назад
The only thing I regret not learning from videos like this is using select to select fields you actully need. One of the databases I work with has over 90 fields in orders table. So not limiting select got me pretty fast in hot water memory wise.
@ayenewyihune
@ayenewyihune Год назад
Very helpful, thanks
@techfuture-code-tv
@techfuture-code-tv 2 года назад
This is a game changer. Thank you great Boss
@rizwansarfraz8389
@rizwansarfraz8389 4 года назад
It could be more memory efficient if you don't need models on your frontend, you can use toBase() just before get(). Then no model will be rendered on fronted and you can save much memory.
@Fenrir-Wolf
@Fenrir-Wolf 4 года назад
I like your tutorials, thank you
@nizomiddinzaripov4655
@nizomiddinzaripov4655 2 года назад
Thank you!
@sajjadshahrabi269
@sajjadshahrabi269 2 года назад
Very very useful. thank you bro. 👏️👏️
@ThibautLefebvre
@ThibautLefebvre 4 года назад
Great video!
@oneestein
@oneestein 3 года назад
Very Helpfull
@SanjayKumar-un7xf
@SanjayKumar-un7xf 3 года назад
Great video :)
@asturias5153
@asturias5153 3 года назад
thanks, very helpful!
@Ahmed-157
@Ahmed-157 2 года назад
You are a genius. Thank you!
@TheAstroguypasa
@TheAstroguypasa 4 года назад
Povilas you are an amazing laravel tutor
@MustafaBirsoz
@MustafaBirsoz 3 года назад
Thanks a lot
@johnolawale2749
@johnolawale2749 4 года назад
Thanks for this
@amgadalwattar2863
@amgadalwattar2863 2 года назад
Thanks🌹
@haonnoah
@haonnoah 4 года назад
Also, you could select only the columns you need depending on the size of your table if you have 50 columns and you only use 3 of them you can use the select function only get back the 3 columns in place off all 50.
@NitishKumarPatra
@NitishKumarPatra 4 года назад
Nice tutorial..
@msdeav
@msdeav 2 года назад
thank you...
@hmanyinja
@hmanyinja 3 года назад
Thanks
@shawyarshah231
@shawyarshah231 2 года назад
Hi, thank you very much for a very useful video. I'm wondering about one thing, what is that you use for showing the Queries, Models, Routes ...etc, is it plugin or extension ? Please thanks for replying in advance.
@jacquesmatike9289
@jacquesmatike9289 3 года назад
Hello ! If I load query results on a variable which take place on memory, what happens if I leave the method where I was ? Do php automatically free up the memory or should I have to unset the variable myself ? Thanks !!
@pauloclara4764
@pauloclara4764 2 года назад
hello using the livewire with modal, if we use the select using the sql table (ex: User:pluck('name','id')) when the page is loaded it will load all the models .. overloading the page .. how to make this load only when the modal is called thanks
@jonasreeve1542
@jonasreeve1542 4 года назад
Hi. First of all I really enjoy watching your videos and am very thankful for your great free content. I am working on a laravel project where I need to schedule a task that deletes model instances daily and keeps a recond of when this task was run etc, how many deletes it made etc. . Can you make a video about Jobs, Queues and Task Scheduling with Laravel? I'm confused on if it's best to use Command, Job and Queue? Thanks!
@PovilasKorop
@PovilasKorop 4 года назад
I have a free video on that, inside of my course "How to structure Laravel project", watch here: laraveldaily.teachable.com/courses/how-to-structure-laravel-project/lectures/8760303
@rohannnsingh84
@rohannnsingh84 3 года назад
That is really very helpful thnkss to u ..just i had a doubt why u used $hotel->bookings_count ...???? Is it mandatory or we can use whatever we want
@jesusephan4482
@jesusephan4482 4 года назад
additionally, memory usage can be decreased by avoiding select *
@paulmimicry9147
@paulmimicry9147 4 года назад
Save me, thank you so much
@bishawjitmondol9284
@bishawjitmondol9284 Месяц назад
Great
@Nscape-dl2js
@Nscape-dl2js 4 года назад
one quick question, i always use the first way (loading relationship in blade file), would you recommend switching to ALWAYS just getting what you need like your example? or just doing this when the query is really getting slow and you have to fix it ? thanks and love the videos they help me a lot.
@nabeelyousafpasha
@nabeelyousafpasha 4 года назад
I would recommend not to do any db hit on blade file. Instead, you must do all your business logic inside controller or service. Because you don't know when data may get bigger and bigger. So must follow Laravel Business' Tip. #justAnAdvice
@PovilasKorop
@PovilasKorop 4 года назад
Always ALWAYS load the DB queries before Blade. Blade is only for SHOWING the data, not for any queries at all. If you follow that rule for small amount of data, it will automatically protect you from the problems with bigger amount of data.
@iamriwash7943
@iamriwash7943 3 года назад
hey how to do multiple theme system in laravel like wordpree . i have newsport and some client want new design for forntend . i dnot wanto to lose my old design for that I want to make theme system multiple how to do ???
@mahmoudmuhammed9585
@mahmoudmuhammed9585 4 года назад
what's extentions used it ?
@codefactory3190
@codefactory3190 3 года назад
How did you get a custom domain on localhost
@tayyabmehr
@tayyabmehr 4 года назад
How to optimize eloquent for jquery Datatables?
@apu6289
@apu6289 5 месяцев назад
Is that normal for over 600 rows via datatables cost 71mb and 1.24s. I got only 24 query for that.
@ridwanhaqi6834
@ridwanhaqi6834 4 года назад
is this work in laravel 5.4?
@kabbajsouheil6792
@kabbajsouheil6792 4 года назад
hello thank you for all your video i would like to ask you please how can i change max file size in spatie media library to upload file more than 2 mb thank you
@PovilasKorop
@PovilasKorop 4 года назад
This article may help: laraveldaily.com/validate-max-file-size-in-laravel-php-and-web-server/
@dekuddus
@dekuddus 4 года назад
It’s an amazing tips, thanks by the way. Dear povilas, I have a request to u to making a tutorial such cases I descibr below please... Many of times we use ready template and they used many jquery plugin and also they have some custom jquery code. So when we trying to convert those theme to vue component system and in that time how can we used those plugin globally with vue or individual components. Thankyou again.
@PovilasKorop
@PovilasKorop 4 года назад
Buying jquery templates and converting them to vue - do you seriously think that it's an efficient way? It's like buying a Mercedes and then trying to fit a BMW details to it, of course they will conflict. There's no "easy" solution for it, or tutorial I can make.
@paulmimicry9147
@paulmimicry9147 4 года назад
I wonder if inner join do the same, faster loading and lower memory usage?
@nabeelyousafpasha
@nabeelyousafpasha 4 года назад
I also wanted to ask same why do TWO queries instead of JOIN (inner, left, right) to hit db once for query. However mySql IN() helps alot. But here's question about JOIN. Thanks in advance.
@PovilasKorop
@PovilasKorop 4 года назад
There's no clear answer to this, depends on how you write that join, it may be even slower. Will shoot a few videos on that, in the future.
@iamriwash7943
@iamriwash7943 2 года назад
hey i have project i use egar losing every thing fine but for the 1st time it take time to load after it take 500ms . first time it take 10sec how to make ?
@LaravelDaily
@LaravelDaily 2 года назад
Do you really think someone can magically debug your errors in a RU-vid comment?
@NjoguAmos
@NjoguAmos Год назад
I want to believe we can even make the performance better by paginating the data.
@47Lancelot
@47Lancelot 4 года назад
I don’t use blade, didnt know you can do such crazy things there :)
@codefactory3190
@codefactory3190 3 года назад
What do you use
@47Lancelot
@47Lancelot 3 года назад
@@codefactory3190 Vue
@vikky20july
@vikky20july 4 года назад
Please share the link of your video in which you have described why not to use "double" as data type for prices
@PovilasKorop
@PovilasKorop 4 года назад
dzone.com/articles/never-use-float-and-double-for-monetary-calculatio
@vikky20july
@vikky20july 4 года назад
@@PovilasKorop Thanks, but i need link of your youtube video in which you have discussed this topic.
@alesiosiriganno3882
@alesiosiriganno3882 4 года назад
Hey Pavlos , thanks for video . Can you do a speed comparison between mysql query with joins , with eloquent relationships used query with() on big data .
@PovilasKorop
@PovilasKorop 4 года назад
To be honest, speed comparison of the same query doesn't really make sense because they are transformed to almost identical queries under the hood. What would make sense is to give example of various Eloquent queries showing what SQL queries are running under the hood and what are possible dangers there. Added to the to-do list.
@mohitverma4724
@mohitverma4724 3 года назад
What if you have to show 100k+ records Or with parent child relation Where you have 20k parents and atleast 2 child of each parent and have to show everything in one page without pagination like a report? What to do then? Any help will be appreciated.
@dvijparekh9401
@dvijparekh9401 4 года назад
Hello Povilas Korop, I am learning laravel in this lockdown situation the problem i am getting is while integrating third party payment gateway {no standard gateway like Paypal or stripe which already have support) but other gateway so when i redirect from my site to payment gateway and then payment gateway sends a response to my site again session and Auth destroys automatically I have gone through many solutions but none of them worked for me if possible please make a video on it
@PovilasKorop
@PovilasKorop 4 года назад
To be honest, I haven't worked with any payment gateways except Stripe and PayPal (and Braintree which is owned by PayPal) so I'm not qualified to make a video on it, sorry.
@silvioney
@silvioney 4 года назад
have you tried to use a unprotected (without CSRF) route to receive this response?
@marekkorcz8857
@marekkorcz8857 3 года назад
I love you
@muaazhammad4446
@muaazhammad4446 2 года назад
cool
@pipe201196
@pipe201196 4 года назад
wawwwwwww is really best
@syrlmhmd
@syrlmhmd 4 года назад
I think use query builder or raw query will be faster, but can you explain the benefit using eloquent instead of query builder or raw query for that case?
@nabeelyousafpasha
@nabeelyousafpasha 4 года назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-3TJfR1Ta4GU.html heres the link from channel.
@syrlmhmd
@syrlmhmd 4 года назад
Thanks, sir.
@silvioney
@silvioney 4 года назад
why use laravel/eloquent and use raw queries?
@neom6
@neom6 2 года назад
Is there any way to loop on 10 million records and sum the result in one column without getting out of memory exception? (all records in the same table no relation need to use )
@LaravelDaily
@LaravelDaily 2 года назад
Do that in SQL query.
@dgloria
@dgloria 4 года назад
Labas Povilas, I'm watching your videos on phone, the font size is very small. It would be nice if you could zoom in. Thank you.
@PovilasKorop
@PovilasKorop 4 года назад
I've zoomed it from default size 14 to 26, if I make it even bigger, then longer rows won't fit on the screen.
@47Lancelot
@47Lancelot 4 года назад
Watch from iPhone X and everything is ok
@tomek.z
@tomek.z 4 года назад
I'm a code performance freak so this is like drug to me. It's also my curse because I won't publish my app untill it's perfect and that means longer production time and lower income. Any advice on how to work on this?
@PovilasKorop
@PovilasKorop 4 года назад
Well, it's simple. If your goal is to release "perfect" apps, then you should be happy, no worries. But if your goal is to make a higher income because you release quicker, then you need to change.
@tomek.z
@tomek.z 4 года назад
@@PovilasKorop I can't change, because I'm addicted to perfection.
@PovilasKorop
@PovilasKorop 4 года назад
@@tomek.z ok no problem, then you likely will have a lower income. Unless you work for clients who do want to invest in "perfect" apps.
@shohanhossain8280
@shohanhossain8280 4 года назад
How to get this bug bar?
@PovilasKorop
@PovilasKorop 4 года назад
github.com/barryvdh/laravel-debugbar
@shohanhossain8280
@shohanhossain8280 4 года назад
Thanks a ton dear!
@JayDelRosario
@JayDelRosario Год назад
@@shohanhossain8280 where do you get it?
@mohamed-pj4qw
@mohamed-pj4qw 4 года назад
what about inner join ? i think it faster than with() 😶.
@robdorn420
@robdorn420 4 года назад
When using an Oracle database the IN Statement has a limit of 1000, so this way is no good for this Db .
@kieronwiltshire1701
@kieronwiltshire1701 Год назад
.4 of a second is terrible performance for such a simple set of queries.
@f00n168
@f00n168 3 года назад
Thank you!
Далее
Eloquent Performance: TOP 3 Mistakes Developers Make
7:59
Eloquent Performance Challenge: My Solution Version
9:57
Pagination in MySQL - offset vs. cursor
13:20
Просмотров 55 тыс.
I tried 8 different Postgres ORMs
9:46
Просмотров 391 тыс.
4 Billion If Statements | Prime Reacts
9:47
Просмотров 601 тыс.
4 Packages You Need in ANY Laravel Project
8:14
Просмотров 61 тыс.
5 tips for supercharged Laravel Eloquent queries
16:29
why do header files even exist?
10:53
Просмотров 376 тыс.
готова дочка 🤣
0:13
Просмотров 10 млн
Косички из морковки 🥕
0:40
Просмотров 9 млн