当我尝试检索大列内容时如何修复“允许的内存大小”

I am trying to retrieve a row with a big content (67MB), but this doesn't finish when it run the query findOrFail, inmediately the log show the error Allowed memory size of 134217728 bytes exhausted (tried to allocate 71224881 bytes)

Then before of the findOrFail add ini_set('memory_limit', '-1'); and it worked, but the problem with the memory limit is that could be crash the web server when the memory run out

Somebody knows how to avoid that error without use the memory limit?

This is my code

// Doesn't work
$file = $query->findOrFail($id);
$file->download($request->filename);
// It works
ini_set('memory_limit', '-1');
$file = $query->findOrFail($id);
$file->download($request->filename);

This is the download method

public function download($contentType = 'application/octet-stream') {
  header("Content-Type: $contentType");
  header("Content-Transfer-Encoding: Binary");
  header("Content-disposition: attachment; filename=\"$this->filename\"");
  echo $this->content;
}