In Mysql table design, an auto-increment column that has nothing to do with the business is usually used as the primary key.
This is because Mysql uses B-Tree index by default, which you can simply understand as "sorted fast search structure".
The following is the structure diagram of a B-Tree, a 2-layer B+ tree, the fan-out of each page is 4; and there are five records from 1 to 6; the upper record saves the minimum value of each page; each page is linked through a doubly linked list Up;
When you insert record 7, page splitting will occur:
As can be seen above, splitting produces record movement, but the optimized split operation does not require record movement:
In InnoDB In the implementation, a position of the last insertion is maintained for each index page, as well as an increment/decrement identifier of the last insertion. Based on this information, InnoDB can determine whether the newly inserted record into the page still satisfies the increment/decrement constraints. If the constraints are met, the optimized splitting strategy will be adopted;
So it is recommended to use a column of sequentially increasing IDs as the primary key. But it doesn’t have to be the autoincrement field of the database, as long as it satisfies the sequential increase. Many large applications will have sequentially increasing ID generators.