I am trying to get a sequential number table from 1 to 20 million. (or 0 to 20 million)
I am rather awestruck at how difficult it\'s been to get a MySQL-compatible s
In response to Devon Bernard's answer, I decided to approach it using PDO Mysql PHP and use the concept of just a few queries. At first I tried to do it with just 1 big query but PHP ran out of memory with default settings, so I decided to tweak to run every 100,000th. Even if you allocate enough memory to hold, there is no significant improvement.
$i = 1;
$inserts = array();
while($i <= 20000000) {
$inserts[] = "($i)";
if($i % 100000 == 0) {
$dbh->beginTransaction();
$query = "INSERT INTO numbers(i) VALUES " . implode(',', $inserts) . ";";
$sth = $dbh->prepare($query);
$sth->execute();
$dbh->commit();
$inserts = array();
}
$i +=1;
}