Original link: Handling Millions of Records in Laravel Eloquent Without Crashing Your App / Ilyas Kazi.
(Eloquent is the builtin ORM in Laravel)