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
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