Why are numbers missing in my primary key with auto-increment?

Using MySQL 5.1.37

This is not a very important issue, one of our business developers just asked about it, and I did not have a good answer. Our user table has a primary key with auto-increment. From time to time, he skips numbers and seems to do it more often. My initial thought was that when two concurrent registrations occurred and one was invalid, that if the second registration was completed and the first was unsuccessful, we would see the missing values, since the second account will use the following identifier. But this does not seem likely due to the frequency with which this occurs. Any ideas?

0
source share
2 answers

I think you are on the right lines with bad settings. This may be the result of transactions "reserving" the primary key, and then the transaction is rolled back. This, of course, assumes that in the table

no delete statements are specified,
0
source

Source: https://habr.com/ru/post/1681535/


All Articles