StackByte - Using chunking and cursors in Laravel to reduce query memory usage.

Поділитися
Вставка
  • Опубліковано 2 лют 2025
  • Working with thousands of record in Laravel is pretty easy - you don't really have to change how you do things, you can just keep on using Eloquent to query data.
    BUT there might come a time where your record sets are in hundreds of thousands, and querying them or making bulk reads, writes or updates might cause a few problems - like running out of memory or running out of execution time.
    Did this video help you? Buy me a coffee here:
    www.buymeacoff...
    Here, we look at a sample Laravel app seeded with 300,000 user records and try various ways of iterating over them all.
    Laravel DebugBar - github.com/bar...
    Wikipedia, Data base Cursors - en.wikipedia.o...

КОМЕНТАРІ • 6

  • @codebeans
    @codebeans Рік тому

    Very well done, beautifully explained!

  • @bartm.6313
    @bartm.6313 2 роки тому

    Dude! This is what i needed! Well explained !

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

    The ending had me dead, 'so there we are, we haven't yet blown up the server, don't forget to subscribe!' xD

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

    Sir, How to implement batch deletion in JPA repository using cursor approach??

  • @lightsupmedia739
    @lightsupmedia739 5 років тому

    cursor or chunk which is better to use (taking account of memory and time)

    • @stackbyte7945
      @stackbyte7945  5 років тому

      It's a balancing act - cursor may put more weight on your database server, whereas chunk shunts the responsibility to loading a number of records in memory in PHP. If you have an application for either, I tend to use chunk first out of habit, then if that's not going so well, try cursor.