Mysql单表有行数限制吗
测试环境
WIN10 PC 2.9Ghz +16G 内存
MySQL5.6
default-storage-engine=MyIsam
max_connections=100
collation-server=utf8_unicode_ci
init_connect='SET NAMES utf8'
innodb_buffer_pool_size=64M
innodb_flush_log_at_trx_commit=1
innodb_lock_wait_timeout=120
innodb_log_buffer_size=4M
innodb_log_file_size=256M
interactive_timeout=120
join_buffer_size=2M
key_buffer_size=32M
log_error_verbosity=1
max_allowed_packet=16M
max_heap_table_size=64M
myisam_max_sort_file_size=64G
myisam_sort_buffer_size=32M
read_buffer_size=512kb
read_rnd_buffer_size=4M
server_id=1
skip-external-locking=on
sort_buffer_size=256kb
table_open_cache=256
thread_cache_size=16
tmp_table_size=64M
wait_timeout=120
测试代码
$db_host = 'localhost';
$db_name = 'testdb';
$db_user = 'root';
$db_pwd = 'root';
$mysqli = new mysqli($db_host, $db_user, $db_pwd, $db_name);
if(mysqli_connect_error()){
echo mysqli_connect_error();
}
$mysqli->set_charset("utf8");
while(true){
$sql = "insert into testdb (`time`) values (".time().")";
$result = $mysqli->query($sql);
if($result === false){
echo $mysqli->error;
echo $mysqli->errno;
}
//影响条数
echo $mysqli->num_rows.PHP_EOL;
//插入的id
echo $mysqli->insert_id.PHP_EOL;
}
$mysqli->close();
运行结果
运行速度很快,每秒10页,一页1000条,10000条/s,内存CPU占用都很低
目前已经 2000万条了 还在运行,待续未完…