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
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.
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.
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
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 ???
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.
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.
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.
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
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.
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 ?
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 !!
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.
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?
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
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 )
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.
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!
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
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?
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.
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 .
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.
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.
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
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.
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.
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.
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
it's got to be a crime to have all these useful information for free sir ! i've got mad respect for you !
Amazing! When working with the big amount of models, I usually use pagination instead of loading all at the first time.
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.
I still didn't work with laravel, just trying to learn to begin a project. Your tips are of great value.
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.
Thank you very much From Uzbekistan Fergana!
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
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 ???
what's extentions used it ?
This is a game changer. Thank you great Boss
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.
Is that normal for over 600 rows via datatables cost 71mb and 1.24s. I got only 24 query for that.
How did you get a custom domain on localhost
I wonder if inner join do the same, faster loading and lower memory usage?
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.
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.
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.
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
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.
have you tried to use a unprotected (without CSRF) route to receive this response?
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 ?
Do you really think someone can magically debug your errors in a UA-cam comment?
Please share the link of your video in which you have described why not to use "double" as data type for prices
dzone.com/articles/never-use-float-and-double-for-monetary-calculatio
@@PovilasKorop Thanks, but i need link of your youtube video in which you have discussed this topic.
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 !!
Povilas you are an amazing laravel tutor
How to optimize eloquent for jquery Datatables?
Very knowledgable video, thanks a lot.
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.
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
WOW, this is an amazing tut. Thank YOU!!!
Thanks so much and i enjoy your tutorial every days.
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?
ua-cam.com/video/3TJfR1Ta4GU/v-deo.html heres the link from channel.
Thanks, sir.
why use laravel/eloquent and use raw queries?
And finally we can use pagination to limit the amount of data.
And finally we can use select to limit the amount of data.
Exactly
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
This article may help: laraveldaily.com/validate-max-file-size-in-laravel-php-and-web-server/
This tut has great value. Thanks a lot!
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 )
Do that in SQL query.
is this work in laravel 5.4?
How to get this bug bar?
github.com/barryvdh/laravel-debugbar
Thanks a ton dear!
@@shohanhossain8280 where do you get it?
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.
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!
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
You are a genius. Thank you!
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?
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.
@@PovilasKorop I can't change, because I'm addicted to perfection.
@@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.
Very very useful. thank you bro. 👏️👏️
I like your tutorials, thank you
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 .
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.
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.
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.
Watch from iPhone X and everything is ok
Thank you!
additionally, memory usage can be decreased by avoiding select *
Great video :)
Great video!
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.
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
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.
thanks, very helpful!
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.
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.
Very Helpfull
Thanks🌹
Nice tutorial..
I don’t use blade, didnt know you can do such crazy things there :)
What do you use
@@codefactory3190 Vue
Thanks for this
Thanks a lot
Thanks
thank you...
Great 👍💯
Very helpful, thanks
what about inner join ? i think it faster than with() 😶.
I want to believe we can even make the performance better by paginating the data.
❤❤❤❤❤❤
Save me, thank you so much
Great
When using an Oracle database the IN Statement has a limit of 1000, so this way is no good for this Db .
wawwwwwww is really best
I love you
cool
.4 of a second is terrible performance for such a simple set of queries.
Thank you!