先插入数据1000w条
<?php
//max_execution_time=100;
ini_set("max_execution_time", 500); //设置为500就是500秒后超时
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "fastadmin2023";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$StartTime = microtime(true);
$sql = "INSERT into fa_json_plc(`topic`,`content`) VALUES ('1','conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2conetn2')";
for($i=0;$i<10000000;$i++) {
if ($conn->query($sql) === TRUE) {
//echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
$StopTime = microtime(true);
$TimeSpent=$StopTime-$StartTime;
echo "<hr>".number_format($TimeSpent*1000, 4).'毫秒';
?>
SELECT * FROM (SELECT * from fa_json_plc ORDER BY id desc limit 100) a GROUP BY topic
select count(*) from fa_json_plc