M
M
Max Ba2018-03-15 11:05:55
MySQL
Max Ba, 2018-03-15 11:05:55

Why do holes appear in ID (AI, InnoDB)?

There is an ID field, primart key autoincrement.
I insert a line, the numbering goes sequentially 999, 1000.
I delete the last line 1000 and insert a new one and there is already a gap of 100 lines.
That is, the next one, not 1001, as logically, but 1100, and so on.
What could be causing this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-03-15
@Rsa97

Gaps in an auto-increment field are usually associated with insert queries that were not executed (queries with execution errors, INSERT IGNORE, INSERT ... ON DUPLICATE KEY UPDATE). Before the request, the required number of new identifiers is reserved and the counter in the table increases, if the request has not added a row, then the numbers allocated to it disappear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question