Optimizing Eloquent: Running Out Of Memory?

Поділитися
Вставка

КОМЕНТАРІ • 101

  • @LaravelDaily
    @LaravelDaily  4 роки тому +14

    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 роки тому +12

    it's got to be a crime to have all these useful information for free sir ! i've got mad respect for you !

  • @henrybui_io
    @henrybui_io 3 роки тому +4

    Amazing! When working with the big amount of models, I usually use pagination instead of loading all at the first time.

  • @TahirBhai
    @TahirBhai 4 роки тому +2

    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.

  • @FortinhoTV
    @FortinhoTV 4 роки тому

    I still didn't work with laravel, just trying to learn to begin a project. Your tips are of great value.

  • @alexrusin
    @alexrusin 4 роки тому +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.

  • @muhammadumarsotvoldiev8768
    @muhammadumarsotvoldiev8768 8 місяців тому +1

    Thank you very much From Uzbekistan Fergana!

  • @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

  • @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 ?

  • @techfuture-code-tv
    @techfuture-code-tv 2 роки тому

    This is a game changer. Thank you great Boss

  • @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.

  • @apu6289
    @apu6289 11 місяців тому

    Is that normal for over 600 rows via datatables cost 71mb and 1.24s. I got only 24 query for that.

  • @codefactory3190
    @codefactory3190 3 роки тому

    How did you get a custom domain on localhost

  • @paulmimicry9147
    @paulmimicry9147 4 роки тому +1

    I wonder if inner join do the same, faster loading and lower memory usage?

    • @nabeelyousafpasha
      @nabeelyousafpasha 4 роки тому +2

      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 роки тому +1

      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.

  • @rizwansarfraz8389
    @rizwansarfraz8389 4 роки тому +7

    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.

  • @dvijparekh9401
    @dvijparekh9401 4 роки тому +1

    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 роки тому +1

      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?

  • @iamriwash7943
    @iamriwash7943 3 роки тому

    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  3 роки тому

      Do you really think someone can magically debug your errors in a UA-cam comment?

  • @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 роки тому +1

      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.

  • @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 !!

  • @TheAstroguypasa
    @TheAstroguypasa 4 роки тому

    Povilas you are an amazing laravel tutor

  • @tayyabmehr
    @tayyabmehr 4 роки тому

    How to optimize eloquent for jquery Datatables?

  • @mdmohithasan1838
    @mdmohithasan1838 2 роки тому

    Very knowledgable video, thanks a lot.

  • @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.

  • @rohannnsingh84
    @rohannnsingh84 4 роки тому

    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

  • @gushung0
    @gushung0 4 роки тому +1

    WOW, this is an amazing tut. Thank YOU!!!

  • @vitouvitou5269
    @vitouvitou5269 4 роки тому

    Thanks so much and i enjoy your tutorial every days.

  • @syrlmhmd
    @syrlmhmd 4 роки тому +1

    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 роки тому +2

      ua-cam.com/video/3TJfR1Ta4GU/v-deo.html heres the link from channel.

    • @syrlmhmd
      @syrlmhmd 4 роки тому

      Thanks, sir.

    • @silvioney
      @silvioney 4 роки тому

      why use laravel/eloquent and use raw queries?

  • @danorex9100
    @danorex9100 4 роки тому +27

    And finally we can use pagination to limit the amount of data.

    • @alexrusin
      @alexrusin 4 роки тому +5

      And finally we can use select to limit the amount of data.

    • @TheCashFlowHQ
      @TheCashFlowHQ 2 роки тому

      Exactly

  • @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/

  • @emilianovargas
    @emilianovargas 4 роки тому

    This tut has great value. Thanks a lot!

  • @neom6
    @neom6 3 роки тому

    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 )

  • @ridwanhaqi6834
    @ridwanhaqi6834 4 роки тому

    is this work in laravel 5.4?

  • @shohanhossain8280
    @shohanhossain8280 4 роки тому

    How to get this bug bar?

  • @shawyarshah231
    @shawyarshah231 3 роки тому

    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.

  • @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 роки тому +1

      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

  • @Ahmed-157
    @Ahmed-157 2 роки тому

    You are a genius. Thank you!

  • @tomek.z
    @tomek.z 4 роки тому +1

    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 роки тому +1

      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 роки тому +2

      @@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.

  • @sajjadshahrabi269
    @sajjadshahrabi269 3 роки тому

    Very very useful. thank you bro. 👏️👏️

  • @Fenrir-Wolf
    @Fenrir-Wolf 4 роки тому

    I like your tutorials, thank you

  • @alesiosiriganno3882
    @alesiosiriganno3882 4 роки тому +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 роки тому +2

      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.

  • @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 роки тому +1

      Watch from iPhone X and everything is ok

  • @f00n168
    @f00n168 3 роки тому

    Thank you!

  • @jesusephan4482
    @jesusephan4482 4 роки тому +1

    additionally, memory usage can be decreased by avoiding select *

  • @SanjayKumar-un7xf
    @SanjayKumar-un7xf 3 роки тому

    Great video :)

  • @ThibautLefebvre
    @ThibautLefebvre 4 роки тому

    Great video!

  • @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 роки тому +2

      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 роки тому +1

      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.

  • @asturias5153
    @asturias5153 3 роки тому

    thanks, very helpful!

  • @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.

  • @oneestein
    @oneestein 4 роки тому

    Very Helpfull

  • @amgadalwattar2863
    @amgadalwattar2863 2 роки тому

    Thanks🌹

  • @NitishKumarPatra
    @NitishKumarPatra 4 роки тому

    Nice tutorial..

  • @47Lancelot
    @47Lancelot 4 роки тому +2

    I don’t use blade, didnt know you can do such crazy things there :)

  • @mojizze
    @mojizze 4 роки тому

    Thanks for this

  • @MustafaBirsoz
    @MustafaBirsoz 3 роки тому

    Thanks a lot

  • @hmanyinja
    @hmanyinja 3 роки тому

    Thanks

  • @msdeav
    @msdeav 2 роки тому

    thank you...

  • @Maha_altaki
    @Maha_altaki 4 місяці тому

    Great 👍💯

  • @ayenewyihune
    @ayenewyihune 2 роки тому

    Very helpful, thanks

  • @mohamed-pj4qw
    @mohamed-pj4qw 4 роки тому

    what about inner join ? i think it faster than with() 😶.

  • @NjoguAmos
    @NjoguAmos 2 роки тому

    I want to believe we can even make the performance better by paginating the data.

  • @Maha_altaki
    @Maha_altaki 4 місяці тому

    ❤❤❤❤❤❤

  • @paulmimicry9147
    @paulmimicry9147 4 роки тому

    Save me, thank you so much

  • @bishawjitmondol9284
    @bishawjitmondol9284 8 місяців тому

    Great

  • @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 .

  • @pipe201196
    @pipe201196 4 роки тому

    wawwwwwww is really best

  • @marekkorcz8857
    @marekkorcz8857 4 роки тому

    I love you

  • @muaazhammad4446
    @muaazhammad4446 2 роки тому

    cool

  • @kieronwiltshire1701
    @kieronwiltshire1701 2 роки тому

    .4 of a second is terrible performance for such a simple set of queries.

  • @zedlineuz
    @zedlineuz 2 роки тому

    Thank you!