I have a table in my database with around 5m records, and I’m noticing the IDs of the each records are not incrementing by one any every insert.
For example, I have the following schema setup:
my_table
activity_id INT(11) PRIMARY (AUTO_INCREMENT), created_at DATETIME
If I look at the table and sort by the DATE TIME, the numbers are not sequential. It actually seems like MySQL is looking for when there is a deletion and then add the new record in there.
Edit Delete 5000089 2012-03-17 04:31:46
Edit Delete 5000087 2012-03-17 04:31:44
Edit Delete 5000086 2012-03-17 04:31:43
Edit Delete 5000085 2012-03-17 04:31:43
Edit Delete 5000084 2012-03-17 04:31:31
**Edit Delete 5000088 2012-03-17 04:31:30**
**Edit Delete 5000076 2012-03-17 04:31:30**
Edit Delete 5000082 2012-03-17 04:31:29
As you can see by the info about, at 4:31:30 GMT, we had 2 inserts, where it should have 83, and 84 but its incrementing weirdly. The database insert from the application does not specify the ID and the field of activity_id is set to Auto_increment.
Any help would be greatly appertained why this happening.
Has anyone see anything like this before?
The auto-increment documentation has this paragraph:
It seems to imply that index values are reused with InnoDB tables, and in certain cases in MyISAM tables. So, if you delete a row, there’s a chance MySQL will create a new row with the old row’s ID.