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 solution to this common problem.
Similar to this: Creating a "Numbers Table" in MySQL
But the answer only goes to 1 million. I am not really understanding the bit shift calculations.
I've seen many SQL answers but most are for databases that aren't MySQL, so I can't adopt the code due to lack of knowledge of both MySQL and the other.
Some references:
SQL, Auxiliary table of numbers
What is the best way to create and populate a numbers table?
Please make sure the code you post is compatible in MySQL and is semicolon delimited so I can run it in PhpMyAdmin. I'd appreciate the table to be named numbers with the column called i
I will benchmark each solution, so the it's archived and hopefully will show up for the next time someone tries to search for this problem.
Benchmarks thus far:
Times are in seconds.
+---------------+------------------+---------+-----------+------------+
|    Author     |      Method      | 10,000  | 1,000,000 | 20,000,000 |
+---------------+------------------+---------+-----------+------------+
| Devon Bernard | PHP Many Queries | 0.38847 | 39.32716  | ~ 786.54   |
| Bhare         | PHP Few Queries  | 0.00831 | 0.94738   | 19.58823   |
| psadac,Bhare  | LOAD DATA        | 0.00549 | 0.43855   | 10.55236   |
| kjtl          | Bitwise          | 1.36076 | 1.48300   | 4.79226    |
+---------------+------------------+---------+-----------+------------+
 
     
     
     
     
     
     
     
    