Somewhere in my Laravel application, the following query is likely to return a very large results set:
$data = $query->join('accommodation_rooms', 'accommodations.id', '=', 'accommodation_rooms.accommodation_id')
->join('discounts', 'accommodation_rooms.id', '=', 'discounts.accommodation_room_id')
->select('accommodation_rooms.id')
->orderBy('discounts.amount', 'desc')
->select('discounts.amount', 'accommodations.*')
->groupBy('discounts.amount', 'accommodation_rooms.id');
return $data;
I wondered how I could load a part of the data faster but only load the rest later maybe using some pagination mechanism or something.
Given the data is sent from an API, I want to know how I could chunk this data.
Thank you.