Laravel DB Insert Error: Allowed Memory Size Exhausted

前端 未结 2 1168
广开言路
广开言路 2021-01-05 16:48

I\'m running into an issue when trying to insert ~20K records into my DB. I notice that even though I\'m echoing inside my foreach loop, I\'m not getting anything outputted

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 17:16

    The accepted answer is fixing the symptom rather then the problem. The problem is the Laravel query log (in memory) is eating all your RAM when you execute such a large # of queries. See the answer here: https://stackoverflow.com/a/18776710/221745

    Or, in brief, turn off query logging via:

    DB::disableQueryLog()
    

    Before executing 20k queries

提交回复
热议问题