I should do really complicated tables reorder.
****The main table looks like:****
id - some data 1 - ... 2 - ... 3 - ... 6 - ... 9 - ... 12 - ...
As you can see, there are "empty" IDs (no 4, 5 between 3 and 6 etc).
****Table should look like****
id - data 1 - ... 2 - ... 3 - ... 4 - ... 5 - ... 6 - ... 7 - ... etc (without empty IDs)
Why do I want to make it: this is a server database, includes millions IDs. The server crashes when maintaining such big numbers. If I reorder IDs and there won't be any empty ones, the MAX ID in this table will be much lower and it will prevent server from crashing.
The most complicated thing - this table has foreign key references (atleast only ID references) in like 4-5 different tables.
My thought is - reorder main table by IDs without empty ones and create new temp table with (oldID, newID) structure and then replace oldID's with newID's in the other related tables.
Any ideas how the query would look like? It will probably take half an hour to execute that query but it's the least problem.