LARAVEL 致命错误异常:允许的 134217728 字节内存已用完(已尝试分配 10489856 字节)

LARAVEL Fatal Error Exception : Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)

我想要运行这个代码

$late = Attendance::whereUserType(5)
         ->where('datetime_in', '!=', null)
         ->where(DB::connection('attendance')
         ->raw('DATE(created_at)'), date('Y-m-d'))
         ->orderBy('user_id')->get()->take(10);

但是我遇到了标题中所说的错误。当我将 memory_limit 更改为 512M 时,我的浏览器出现延迟。我正在使用 16K+ 数据进行测试,可以吗??问题是什么??

尝试反转搜索方式,将 get()->take(10) 更改为 take(10)-> get()

尝试在脚本之上添加这个

ini_set('memory_limit','512M');

您的查询可能超时