Hi @wshealy,
Internally, WordPress doesn’t need the blog_ids to be sequential, skipping numbers won’t cause issues.
Deleting a site will cause that ID not to be re-used (the site will usually continue to exist anyway, occupying that ID, just marked as deleted/inaccessible). But in the event that a site is completely erased, that ID would normally still not be re-used, just to prevent any issues around cache or stored IDs elsewhere.
Once a site is created however, changing the ID of it (without destroying the site and re-creating it) is not advisable for many reasons unless you’re 100% sure you know what you’re getting into ??
How does multisite determine the next blog_id and where is the database is it stored?
WordPress relies upon MySQL (or MariaDB, whatever provides your DB) to provide it the blog ID, the conversation goes something like..
WordPress: Hey MySQL, store these new Blog details!
MySQL: Ok! That’s ID 23.
This comes from the AUTO_INCREMENT
table field on the wp_blogs
table, MySQL keeps track of the next ID that should be used when a record is inserted. It’s possible to set it to 1,000 when creating a table, and records will be created with IDs 1000, 1001, 1002 skipping IDs 1~999.
If you were to delete the blog_id 23, all of it’s table, and ensure it no longer exists within wp_blogs
you could then reset the Auto Increment value on the table to the next ID you wish to be used, such as 5.
But just to re-iterate, skipping IDs 5-22 is not a problem, WordPress will continue to operate as normal, blog counts won’t be incorrect, WordPress will actually count the records in the database.