Dal manuale MySQL:
codice:
...
Suppose that there are two transactions running, each inserting rows into a table with an AUTO_INCREMENT column.
One transaction is using an INSERT ... SELECT statement that inserts 1000 rows,
and another is using a simple INSERT statement that inserts one row:
Tx1: INSERT INTO t1 (c2) SELECT 1000 rows from another table ...
Tx2: INSERT INTO t1 (c2) VALUES ('xxx');
InnoDB cannot tell in advance how many rows will be retrieved from the SELECT
in the INSERT statement in Tx1, and it assigns the auto-increment values one at a time
as the statement proceeds.
With a table-level lock, held to the end of the statement, only one INSERT statement
referring to table t1 can execute at a time, and the generation of auto-increment
numbers by different statements is not interleaved.
The auto-increment value generated by the Tx1 INSERT ... SELECT statement
will be consecutive, and the (single) auto-increment value used by the INSERT
statement in Tx2 will either be smaller or larger than all those used for Tx1,
depending on which statement executes first.
...
Non dovrebbero esserci problemi se utilizzi transazioni in quanto un eventuale accesso contemporaneo genererà comunque in ID (auto_increment) differente (superiore o inveriore) a seconda dell'ordine di esecuzione delle transazioni.