Simplified Way of Processing Large Data Using Chunk in Laravel
Simplified Way of Processing Large Data Using Chunk in Laravel
processing large
data using chunk() in
laravel
Learn More
TABLE OF CONTENTS
https://decodeweb.in
Simplified way of processing large data using chunk() in
laravel
Source: https://decodeweb.in/php/simplified-way-of-processing-large-data-using-chunk-in-laravel/
PHP takes data into its allocated memory on server and then process further, also it automatically lends some
extra bytes if it thinks it would be sufficient for the script to run and exit successfully. All these actions are
handled automatically until the records are less 1000 but once it crosses this limit server resources become
deficient of memory.
In short, server stops responding to other requests and many script is exited abruptly, which we call it as a
memory leakage. In return, we get a Fatal error: Allowed memory size of <some_number> bytes
exhausted (tried to allocate <some_number> bytes)
On the other hand, when the calculation during data processing is way too much complex then script would
exit abruptly because each script has a definite execution time allocated.
Now you may wonder, that we can manually change these settings in php.ini file but I do not recommend to
mess with any configuration file on the production server unless it is the last resort.
<?php
<?php
Namespace App\Http\Controller;
Use User;
<?php
$a = 500;
unset($a);
?>
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
mysqli_close($con);
?>