I have a MySQL 5.5 (5.5.45-1+deb.sury.org~trusty+1-log) in Ubuntu and I am hitting a strange behaivior when executing a migration query.
The query is like this:
insert into db1.table1 (col2)
select col2
from db2.table1 as a
inner join db1.table2 as d on a.id = d.uuid
inner join db1.table3 as c on a.id = c.uuid
where c.id = 2;
After that query I get data like this:
1 xxx
2 xxx
3 xxx
After that I execute single inserts like this:
insert into db1.table1 (col2) values('xxx');
insert into db1.table1 (col2) values('xxx');
insert into db1.table1 (col2) values('xxx');
And I get a jump in the autoincrement:
1 xxx
2 xxx
3 xxx
34 xxx
35 xxx
36 xxx
That jump is always deterministic after executing the first query.
Does anyone knows why is this happening?
How can I ensure that after the migration of data the next registries get the correct Id?
Thanks!
I found that is a known issue of mysql 5. Mysql auto increment jumps when insert-select
So I think this is a bug.