MySQL auto_increment vs max
3 answers
The problem with using MAX is the isolation level - at best, the probability of exceeding the value is overestimated due to reading records, this may be incorrect. In the worst case, the query to select the current maximum value reads the table before the previous insert occurs, causing a collision.
Another consideration is that you need to roll your own id generator and stuff to get the id, because you cannot use LAST_INSERT_ID()
.
+2
source to share