Maybe you can use an include here? `user_project.merge_request.includes(:notes).find(params[:merge_request_id])` That way, rails will create a better optimised query.