When I try to select a paginated connection request field, it shows an en error, for example
Allowed memory size of 134217728 bytes exhausted (tried to allocate 45797376 bytes)
My request
$price_all = DB::table('model_price')
->join('operator_model','model_price.model_id','=','operator_model.id')
->join('operator_route','operator_model.operator_route_id','=','operator_route.id')
->join('route', 'operator_route.route_id', '=', 'route.id')
->join('operator', 'operator_route.operator_id', '=', 'operator.id')
->select('model_price.id', 'model_price.price', 'route.route_name', 'operator.operator_name')
->paginate(2);
My database contains only 5 records. this is not big data.
when I try without pagination, then it works fine. as
$price_all = DB::table('model_price')
->join('operator_model','model_price.model_id','=','operator_model.id')
->join('operator_route','operator_model.operator_route_id','=','operator_route.id')
->join('route', 'operator_route.route_id', '=', 'route.id')
->join('operator', 'operator_route.operator_id', '=', 'operator.id')
->select('model_price.id', 'model_price.price', 'route.route_name', 'operator.operator_name')
->get();
Now, how can I optimize this query.