I see it like when you paginate a query. But in the collection you only retrieve so much at a time.
To me collections aren't worth it for most things, Just paginate or use chunk on the data. But for small data sets that need some calculations or something, then an array or collection is fine.
@jlrdw I checked the docs before posting this thread, I understand how Lazy-collections works, but I do not know why there is no memory issue when using cursor method. Since it loads all the records into memory as well.
However, the query builder's cursor method returns a LazyCollection instance. This allows you to still only run a single query against the database but also only keep one Eloquent model loaded in memory at a time.
Note this part:
but also only keep one Eloquent model loaded in memory at a time.