PHP+Mysql 测试百万数据导入

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012972536/article/details/78962027

测试PHP+mysql 百万数据入库

<?php

$servername = '127.0.0.1';
$username = 'root';
$password = 'root';
$con = mysqli_connect($servername,$username,$password, 'xp_db');
if (empty($con))
	exit('connection failed');

$sql = '';
for($i=0;$i<1000000;$i++){
	$sql.= '(' . $i . '),';
};
$sql = substr($sql, 0, strlen($sql)-1);

$sTime = explode(' ',microtime());
echo microtime();

mysqli_query($con, "INSERT INTO test_multi_import (value) VALUES $sql");

$eTime = explode(' ',microtime());
echo PHP_EOL;
echo microtime();

$thistime = $eTime[0]+$eTime[1]-($sTime[0]+$sTime[1]);
$thistime = round($thistime,3);
echo PHP_EOL;
echo 'It tasks ' . $thistime . ' seconds!';
exit;

点击   http://wp.wecot.cn/  学习更多服务器知识!

猜你喜欢

转载自blog.csdn.net/u012972536/article/details/78962027