Why do IDs of deleted nodes remain in the database?

Luxus

Well-known member
Each node has a unique ID assigned to it, but if I delete a node I expect the node ID to be deleted too, but it's not. For example if you have 10 nodes and delete all of them, then create another node, this node will get the node ID of 11.

Any reason for this?
 
This is just how MySQL works.

The node ID is an auto increment value. The index of these values remain, even after its associated record is removed.

I believe the only way to resolve this is to somehow remove the index.

I believe truncating a table will do this (as well as removing all the data from it) so not really useful.
 
If you are absolutely sure that your last node ID was not referenced anywhere, you could reset the auto increment thus:
ALTER TABLE xf_node AUTO_INCREMENT = X;
Where X will be the ID of the next node you insert.
 
If you are absolutely sure that your last node ID was not referenced anywhere, you could reset the auto increment thus:
ALTER TABLE xf_node AUTO_INCREMENT = X;
Where X will be the ID of the next node you insert.

IF you do that you will wonder why so many threads appear in your brand new forum node after you set it up. :D
 
Top Bottom