I am new to amazon web services and have set up a mySQL RDS instance.
I am currently using the db.t2.micro server and have set up a loop which inserts 1000 records into the database. As we can see from the code this operation takes around 16 seconds to complete.
If I were aiming to be getting the speed down to have the 1000 inserts completed in 1 second, what specs would I need to be looking at changing to achieve this?
<?php
$time = time();
// connection crednetials
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$i = 0;
while($i < 1000){
$sql = "INSERT INTO test (value)
VALUES ('$i')";
if ($conn->query($sql) === TRUE) {
// echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$i++;
}
$conn->close();
$time2 = time();
$diff = $time2 - $time;
echo "Difference: ".$diff;
?>
thanks!