I have to insert around 75000 numbers of data which is to be retrieved from another table calculation. I have tried the following code.
$start = new DateTime('2018-09-01');
$end = new DateTime('2018-12-31');
$interval = DateInterval::createFromDateString('1 month');
$period = new DatePeriod($start, $interval, $end);
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
foreach ($period as $dt) {
$inputyear = $dt->format("Y");
$inputmonth = $dt->format("m");
Sql = " insert into tbl1()select from ... "
//HERE I JOIN 3 tables
$result = $conn->query($sql);
}
$conn->close();
Its giving me timeout error. I have tried increasing the wamp timeout to 300 as well but it didnot work. How can I optimize above code?